@leitwerk-dev/github 0.2.0 → 0.3.0
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 +40 -0
- package/dist/authorization.d.ts +4 -0
- package/dist/authorization.d.ts.map +1 -1
- package/dist/binding.d.ts +1 -0
- package/dist/binding.d.ts.map +1 -1
- package/dist/capability.d.ts +6 -1
- package/dist/capability.d.ts.map +1 -1
- package/dist/{chunk-PVE52UFH.js → chunk-OAOKE6LC.js} +162 -20
- package/dist/chunk-OAOKE6LC.js.map +1 -0
- package/dist/client.d.ts +143 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/external.d.ts +66 -0
- package/dist/external.d.ts.map +1 -1
- package/dist/index.d.ts +13 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +160 -168
- package/dist/index.js.map +1 -1
- package/dist/issue-provider.d.ts.map +1 -1
- package/dist/issue-watcher.d.ts +12 -0
- package/dist/issue-watcher.d.ts.map +1 -1
- package/dist/poll-report.d.ts +2 -18
- package/dist/poll-report.d.ts.map +1 -1
- package/dist/provider.d.ts +3 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/testing/tool-fixture.d.ts +192 -0
- package/dist/testing/tool-fixture.d.ts.map +1 -0
- package/dist/testing.d.ts +67 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +46 -4
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/authorization.ts +9 -1
- package/src/binding.ts +1 -0
- package/src/capability.ts +6 -1
- package/src/client.ts +315 -28
- package/src/external.ts +54 -0
- package/src/index.ts +33 -11
- package/src/issue-provider.ts +4 -12
- package/src/issue-watcher.ts +16 -1
- package/src/poll-report.ts +5 -23
- package/src/provider.ts +1 -1
- package/src/testing/tool-fixture.ts +137 -0
- package/src/testing.ts +108 -9
- package/src/tools.ts +183 -175
- package/dist/chunk-PVE52UFH.js.map +0 -1
package/src/tools.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type ExternalWriteLogRepoLike,
|
|
4
|
-
ensureWrite,
|
|
5
|
-
recordWriteIfMissing,
|
|
6
|
-
} from "@leitwerk-dev/external-writes";
|
|
7
|
-
import {
|
|
2
|
+
existingObject,
|
|
8
3
|
type IntegrationToolExecutionContext,
|
|
4
|
+
matchesPatch,
|
|
9
5
|
numberArg,
|
|
10
6
|
objectArg,
|
|
11
7
|
projectParameters,
|
|
@@ -18,21 +14,7 @@ import { assertGitHubRepository } from "./client.js";
|
|
|
18
14
|
|
|
19
15
|
const object = (value: unknown) => objectArg(value, "Expected an object");
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
comments: Promise<Array<{ body?: unknown }>>,
|
|
23
|
-
marker: string,
|
|
24
|
-
body: () => string,
|
|
25
|
-
post: (body: string) => Promise<unknown>,
|
|
26
|
-
) {
|
|
27
|
-
const existing = (await comments).find((comment) => String(comment.body).includes(marker));
|
|
28
|
-
return existing ?? post(`${body()}\n\n${marker}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function registerGitHubTools(
|
|
32
|
-
api: ServerExtensionAPI,
|
|
33
|
-
integration: GitHubIntegration,
|
|
34
|
-
writes: ExternalWriteLogRepoLike,
|
|
35
|
-
) {
|
|
17
|
+
export function registerGitHubTools(api: ServerExtensionAPI, integration: GitHubIntegration) {
|
|
36
18
|
const target = (ctx: IntegrationToolExecutionContext) => {
|
|
37
19
|
const binding = resolveGitHubProjectBinding(ctx);
|
|
38
20
|
assertGitHubRepository(
|
|
@@ -45,11 +27,7 @@ export function registerGitHubTools(
|
|
|
45
27
|
api.tool({
|
|
46
28
|
name: "github_resolve_git_identity",
|
|
47
29
|
description: "Resolve the configured GitHub Git identity",
|
|
48
|
-
parameters:
|
|
49
|
-
type: "object",
|
|
50
|
-
properties: { projectKey: { type: "string" } },
|
|
51
|
-
required: ["projectKey"],
|
|
52
|
-
},
|
|
30
|
+
parameters: projectParameters(),
|
|
53
31
|
async execute(ctx) {
|
|
54
32
|
const t = target(ctx);
|
|
55
33
|
return integration.client(t.profile).resolveGitIdentity(t.profile);
|
|
@@ -61,103 +39,168 @@ export function registerGitHubTools(
|
|
|
61
39
|
"github_add_issue_comment",
|
|
62
40
|
"github_add_pull_request_feedback_reaction",
|
|
63
41
|
"github_reply_to_pull_request_feedback",
|
|
42
|
+
"github_add_pull_request_comment",
|
|
43
|
+
"github_update_pull_request",
|
|
64
44
|
] as const) {
|
|
45
|
+
const pullRequest =
|
|
46
|
+
name === "github_add_pull_request_comment" || name === "github_update_pull_request";
|
|
47
|
+
const update = name === "github_update_issue" || name === "github_update_pull_request";
|
|
65
48
|
api.tool({
|
|
66
49
|
name,
|
|
67
|
-
description:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
description: pullRequest
|
|
51
|
+
? update
|
|
52
|
+
? "Update a GitHub pull request"
|
|
53
|
+
: "Comment on a GitHub pull request"
|
|
54
|
+
: "Reconcile GitHub delivery in the current process project",
|
|
55
|
+
parameters: pullRequest
|
|
56
|
+
? projectParameters(
|
|
57
|
+
{
|
|
58
|
+
pullRequestNumber: { type: "integer" },
|
|
59
|
+
...(update
|
|
60
|
+
? { patch: { type: "object" } }
|
|
61
|
+
: { body: { type: "string" }, writeKey: { type: "string" } }),
|
|
62
|
+
},
|
|
63
|
+
["pullRequestNumber", update ? "patch" : "body"],
|
|
64
|
+
)
|
|
65
|
+
: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
projectKey: { type: "string" },
|
|
69
|
+
issueNumber: { type: "integer" },
|
|
70
|
+
pullRequestNumber: { type: "integer" },
|
|
71
|
+
name: { type: "string" },
|
|
72
|
+
patch: { type: "object" },
|
|
73
|
+
body: { type: "string" },
|
|
74
|
+
feedbackKind: { type: "string" },
|
|
75
|
+
feedbackId: { type: "integer" },
|
|
76
|
+
writeKey: { type: "string" },
|
|
77
|
+
},
|
|
78
|
+
required: ["projectKey"],
|
|
79
|
+
},
|
|
83
80
|
async execute(ctx, args) {
|
|
84
81
|
const input = object(args);
|
|
85
82
|
const t = target(ctx);
|
|
86
83
|
const client = integration.client(t.profile);
|
|
87
84
|
const key =
|
|
88
|
-
typeof input.writeKey === "string"
|
|
85
|
+
!(pullRequest && update) && typeof input.writeKey === "string"
|
|
86
|
+
? stringArg(input, "writeKey")
|
|
87
|
+
: ctx.idempotencyKey;
|
|
88
|
+
const signal = pullRequest ? ctx.signal : undefined;
|
|
89
89
|
const marker = `<!-- leitwerk-write:${ctx.process.id}:${key} -->`;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
: client.replyFeedback(
|
|
90
|
+
const issueNumber = () =>
|
|
91
|
+
numberArg(
|
|
92
|
+
input,
|
|
93
|
+
pullRequest || input.issueNumber == null ? "pullRequestNumber" : "issueNumber",
|
|
94
|
+
);
|
|
95
|
+
const findComment = async () => {
|
|
96
|
+
const replies =
|
|
97
|
+
name === "github_reply_to_pull_request_feedback"
|
|
98
|
+
? await client.listFeedbackReplies(
|
|
99
|
+
t.owner,
|
|
100
|
+
t.repo,
|
|
101
|
+
issueNumber(),
|
|
102
|
+
stringArg(input, "feedbackKind"),
|
|
103
|
+
)
|
|
104
|
+
: await client.listIssueComments(t.owner, t.repo, issueNumber(), signal);
|
|
105
|
+
return (
|
|
106
|
+
replies.find(
|
|
107
|
+
(comment) =>
|
|
108
|
+
String(comment.body).includes(marker) &&
|
|
109
|
+
(name !== "github_reply_to_pull_request_feedback" ||
|
|
110
|
+
input.feedbackKind !== "inline" ||
|
|
111
|
+
object(comment).in_reply_to_id === numberArg(input, "feedbackId")),
|
|
112
|
+
) ?? null
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
const result = await ctx.externalWrites.ensure(
|
|
116
|
+
{
|
|
117
|
+
writeType: pullRequest ? (update ? "github.update_pr" : "github.comment") : name,
|
|
118
|
+
dedupKey: key,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
reconcile: async (phase): Promise<object | null> =>
|
|
122
|
+
existingObject(async () => {
|
|
123
|
+
if (name === "github_ensure_label")
|
|
124
|
+
return (
|
|
125
|
+
(await client.listLabels(t.owner, t.repo)).find(
|
|
126
|
+
(label) => label.name === stringArg(input, "name"),
|
|
127
|
+
) ?? null
|
|
128
|
+
);
|
|
129
|
+
if (update) {
|
|
130
|
+
const current = await client[pullRequest ? "getPullRequest" : "getIssue"](
|
|
131
|
+
t.owner,
|
|
132
|
+
t.repo,
|
|
133
|
+
issueNumber(),
|
|
134
|
+
signal,
|
|
135
|
+
);
|
|
136
|
+
return current &&
|
|
137
|
+
(phase === "already_recorded" || matchesPatch(current, object(input.patch)))
|
|
138
|
+
? current
|
|
139
|
+
: null;
|
|
140
|
+
}
|
|
141
|
+
if (name === "github_add_pull_request_feedback_reaction")
|
|
142
|
+
return (
|
|
143
|
+
(
|
|
144
|
+
await client.listFeedbackReactions(
|
|
146
145
|
t.owner,
|
|
147
146
|
t.repo,
|
|
148
|
-
issueNumber,
|
|
149
147
|
stringArg(input, "feedbackKind"),
|
|
150
148
|
numberArg(input, "feedbackId"),
|
|
151
|
-
|
|
149
|
+
)
|
|
150
|
+
).find(
|
|
151
|
+
(reaction) =>
|
|
152
|
+
reaction.content === "eyes" &&
|
|
153
|
+
reaction.user.login.toLowerCase() === client.profile.botLogin.toLowerCase(),
|
|
154
|
+
) ?? null
|
|
155
|
+
);
|
|
156
|
+
return findComment();
|
|
157
|
+
}),
|
|
158
|
+
execute: async (): Promise<object> => {
|
|
159
|
+
if (name === "github_ensure_label")
|
|
160
|
+
return client.createLabel(t.owner, t.repo, stringArg(input, "name"));
|
|
161
|
+
if (update)
|
|
162
|
+
return pullRequest
|
|
163
|
+
? object(
|
|
164
|
+
await client.updatePullRequest(
|
|
165
|
+
t.owner,
|
|
166
|
+
t.repo,
|
|
167
|
+
issueNumber(),
|
|
168
|
+
object(input.patch),
|
|
169
|
+
signal,
|
|
152
170
|
),
|
|
171
|
+
)
|
|
172
|
+
: client.updateIssue(t.owner, t.repo, issueNumber(), object(input.patch));
|
|
173
|
+
if (name === "github_add_pull_request_feedback_reaction")
|
|
174
|
+
return object(
|
|
175
|
+
await client.addFeedbackReaction(
|
|
176
|
+
t.owner,
|
|
177
|
+
t.repo,
|
|
178
|
+
stringArg(input, "feedbackKind"),
|
|
179
|
+
numberArg(input, "feedbackId"),
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
const body = `${stringArg(input, "body")}\n\n${marker}`;
|
|
183
|
+
return object(
|
|
184
|
+
await (name === "github_add_issue_comment" || pullRequest
|
|
185
|
+
? client.addIssueComment(t.owner, t.repo, issueNumber(), body, signal)
|
|
186
|
+
: client.replyFeedback(
|
|
187
|
+
t.owner,
|
|
188
|
+
t.repo,
|
|
189
|
+
issueNumber(),
|
|
190
|
+
stringArg(input, "feedbackKind"),
|
|
191
|
+
numberArg(input, "feedbackId"),
|
|
192
|
+
body,
|
|
193
|
+
)),
|
|
153
194
|
);
|
|
154
|
-
}
|
|
155
|
-
|
|
195
|
+
},
|
|
196
|
+
toMetadata: (value) =>
|
|
197
|
+
pullRequest
|
|
198
|
+
? { owner: t.owner, repo: t.repo, pullRequestNumber: issueNumber() }
|
|
199
|
+
: { value },
|
|
156
200
|
},
|
|
157
201
|
);
|
|
158
|
-
|
|
159
202
|
if (name === "github_ensure_label") return { name: stringArg(input, "name") };
|
|
160
|
-
return
|
|
203
|
+
return result;
|
|
161
204
|
},
|
|
162
205
|
});
|
|
163
206
|
}
|
|
@@ -182,31 +225,20 @@ export function registerGitHubTools(
|
|
|
182
225
|
(await client.listPullRequests(t.owner, t.repo, "all")).find(
|
|
183
226
|
(candidate) => candidate.head.ref === head && candidate.base.ref === base,
|
|
184
227
|
) ?? null;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
228
|
+
return ctx.externalWrites.ensure(
|
|
229
|
+
{ writeType: "github.ensure_pr", dedupKey: ctx.idempotencyKey },
|
|
230
|
+
{
|
|
231
|
+
reconcile: () => existingObject(find),
|
|
232
|
+
execute: () =>
|
|
233
|
+
client.createPullRequest(t.owner, t.repo, {
|
|
191
234
|
title: stringArg(input, "title"),
|
|
192
235
|
body: stringArg(input, "body"),
|
|
193
236
|
head,
|
|
194
237
|
base,
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
pr = await find();
|
|
200
|
-
if (!pr) throw error;
|
|
201
|
-
}
|
|
202
|
-
pr ??= await find();
|
|
203
|
-
}
|
|
204
|
-
if (!pr) throw new Error("GitHub pull request creation could not be reconciled");
|
|
205
|
-
recordWriteIfMissing(writes, ctx.process.id, identity, {
|
|
206
|
-
number: pr.number,
|
|
207
|
-
url: pr.html_url,
|
|
208
|
-
});
|
|
209
|
-
return pr;
|
|
238
|
+
}),
|
|
239
|
+
toMetadata: (pr) => ({ number: pr.number, url: pr.html_url }),
|
|
240
|
+
},
|
|
241
|
+
);
|
|
210
242
|
},
|
|
211
243
|
});
|
|
212
244
|
for (const [name, description, numberName, method] of [
|
|
@@ -241,6 +273,31 @@ export function registerGitHubTools(
|
|
|
241
273
|
},
|
|
242
274
|
});
|
|
243
275
|
}
|
|
276
|
+
api.tool<Record<string, unknown>>({
|
|
277
|
+
name: "github_get_ci_diagnostics",
|
|
278
|
+
description:
|
|
279
|
+
"Read failed check annotations and bounded Actions logs for the current request revision",
|
|
280
|
+
parameters: projectParameters(
|
|
281
|
+
{ pullRequestNumber: { type: "integer" }, headSha: { type: "string" } },
|
|
282
|
+
["pullRequestNumber", "headSha"],
|
|
283
|
+
),
|
|
284
|
+
async execute(ctx, input) {
|
|
285
|
+
const t = target(ctx);
|
|
286
|
+
const client = integration.client(t.profile);
|
|
287
|
+
const number = numberArg(input, "pullRequestNumber");
|
|
288
|
+
const pr = await client.getPullRequest(t.owner, t.repo, number, ctx.signal);
|
|
289
|
+
if (pr.head.ref !== ctx.project?.workBranch || pr.base.ref !== ctx.project.baseBranch)
|
|
290
|
+
throw new Error("Pull request does not belong to the process branches");
|
|
291
|
+
return client.getCiDiagnostics(
|
|
292
|
+
t.owner,
|
|
293
|
+
t.repo,
|
|
294
|
+
number,
|
|
295
|
+
stringArg(input, "headSha"),
|
|
296
|
+
ctx.signal,
|
|
297
|
+
);
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
|
|
244
301
|
api.tool<Record<string, unknown>>({
|
|
245
302
|
name: "github_get_checks",
|
|
246
303
|
description: "Read GitHub Actions check runs for a commit",
|
|
@@ -252,53 +309,4 @@ export function registerGitHubTools(
|
|
|
252
309
|
.getCheckSummary(t.owner, t.repo, stringArg(input, "headSha"));
|
|
253
310
|
},
|
|
254
311
|
});
|
|
255
|
-
for (const definition of [
|
|
256
|
-
{ name: "github_add_pull_request_comment", update: false },
|
|
257
|
-
{ name: "github_update_pull_request", update: true },
|
|
258
|
-
] as const) {
|
|
259
|
-
api.tool<Record<string, unknown>>({
|
|
260
|
-
name: definition.name,
|
|
261
|
-
description: definition.update
|
|
262
|
-
? "Update a GitHub pull request"
|
|
263
|
-
: "Comment on a GitHub pull request",
|
|
264
|
-
parameters: projectParameters(
|
|
265
|
-
{
|
|
266
|
-
pullRequestNumber: { type: "integer" },
|
|
267
|
-
...(definition.update
|
|
268
|
-
? { patch: { type: "object" } }
|
|
269
|
-
: { body: { type: "string" }, writeKey: { type: "string" } }),
|
|
270
|
-
},
|
|
271
|
-
["pullRequestNumber", definition.update ? "patch" : "body"],
|
|
272
|
-
),
|
|
273
|
-
async execute(ctx, input) {
|
|
274
|
-
const t = target(ctx);
|
|
275
|
-
const pr = numberArg(input, "pullRequestNumber");
|
|
276
|
-
const key =
|
|
277
|
-
!definition.update && typeof input.writeKey === "string"
|
|
278
|
-
? stringArg(input, "writeKey")
|
|
279
|
-
: ctx.idempotencyKey;
|
|
280
|
-
return ensureWrite(
|
|
281
|
-
writes,
|
|
282
|
-
ctx.process.id,
|
|
283
|
-
createWriteIdentity(definition.update ? "github.update_pr" : "github.comment", key),
|
|
284
|
-
async () => {
|
|
285
|
-
if (definition.update)
|
|
286
|
-
await integration
|
|
287
|
-
.client(t.profile)
|
|
288
|
-
.updatePullRequest(t.owner, t.repo, pr, object(input.patch), ctx.signal);
|
|
289
|
-
else {
|
|
290
|
-
const client = integration.client(t.profile);
|
|
291
|
-
await reconcileComment(
|
|
292
|
-
client.listIssueComments(t.owner, t.repo, pr, ctx.signal),
|
|
293
|
-
`<!-- leitwerk-write:${ctx.process.id}:${key} -->`,
|
|
294
|
-
() => stringArg(input, "body"),
|
|
295
|
-
(body) => client.addIssueComment(t.owner, t.repo, pr, body, ctx.signal),
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
return { owner: t.owner, repo: t.repo, pullRequestNumber: pr };
|
|
299
|
-
},
|
|
300
|
-
);
|
|
301
|
-
},
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
312
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/authorization.ts","../src/client.ts"],"sourcesContent":["import type { GitHubClient, GitHubFeedbackItem, GitHubIssue } from \"./client.js\";\n\ntype MembershipClient = Pick<GitHubClient, \"profile\" | \"isOrganizationMember\">;\n\nexport async function authorizedTrigger(\n\tclient: MembershipClient & Pick<GitHubClient, \"getIssue\" | \"listIssueEvents\">,\n\towner: string,\n\trepo: string,\n\tnumber: number,\n\ttrigger: string,\n\tdone: string,\n) {\n\tif (\n\t\tclient.profile.allowedOrganization &&\n\t\towner.toLowerCase() !== client.profile.allowedOrganization.toLowerCase()\n\t)\n\t\treturn null;\n\tconst issue = (await client.getIssue(owner, repo, number)) as GitHubIssue & {\n\t\tpull_request?: unknown;\n\t};\n\tif (\n\t\tissue.pull_request ||\n\t\tissue.state !== \"open\" ||\n\t\t!issue.labels.some((label) => label.name === trigger) ||\n\t\tissue.labels.some((label) => label.name === done)\n\t)\n\t\treturn null;\n\tconst last = (await client.listIssueEvents(owner, repo, number))\n\t\t.filter(\n\t\t\t(event) =>\n\t\t\t\t(event.event === \"labeled\" || event.event === \"unlabeled\") && event.label?.name === trigger,\n\t\t)\n\t\t.sort((a, b) => b.id - a.id)[0];\n\tif (\n\t\tlast?.event !== \"labeled\" ||\n\t\t!last.actor?.login ||\n\t\t!(await client.isOrganizationMember(last.actor.login))\n\t)\n\t\treturn null;\n\treturn { issue, actor: last.actor.login, eventId: last.id };\n}\n\nexport async function actionableFeedback(client: MembershipClient, feedback: GitHubFeedbackItem[]) {\n\tconst authorized: GitHubFeedbackItem[] = [];\n\tfor (const item of feedback) {\n\t\tif (\n\t\t\titem.author.toLowerCase() === client.profile.botLogin.toLowerCase() ||\n\t\t\titem.body.includes(\"<!-- leitwerk-write:\")\n\t\t)\n\t\t\tcontinue;\n\t\tif (await client.isOrganizationMember(item.author)) authorized.push(item);\n\t}\n\treturn authorized;\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype RepositoryFeedbackItem as GitHubFeedbackItem,\n\ttype RepositoryIssue as GitHubIssue,\n\ttype RepositoryPullRequest as GitHubPullRequest,\n\tIntegrationHttpError,\n\tnormalizeRepositoryFeedback as normalize,\n\tRepositoryHttpClient,\n} from \"@leitwerk-dev/process-sdk\";\n\nimport { actionableFeedback, authorizedTrigger } from \"./authorization.js\";\n\nexport type { GitHubFeedbackItem, GitHubIssue, GitHubPullRequest };\n\nexport interface GitHubRepository {\n\tname: string;\n\tfull_name: string;\n\towner: { login: string };\n\tssh_url: string;\n\tdefault_branch: string;\n\thtml_url: string;\n\tarchived: boolean;\n\thas_issues: boolean;\n}\nexport interface GitHubGitIdentity {\n\tprovider: \"github\";\n\tprofile: string;\n\tlogin: string;\n\tname: string;\n\temail: string;\n}\nexport interface GitHubLabelEvent {\n\tid: number;\n\tevent: string;\n\tlabel?: { name: string };\n\tactor: { login: string } | null;\n}\n\nexport interface GitHubProfile {\n\tapiBaseUrl: string;\n\ttoken: string;\n\tbotLogin: string;\n\tallowedOrganization?: string;\n}\n\nexport interface GitHubCheckSummary {\n\theadSha: string;\n\tstatus: \"pending\" | \"success\" | \"failure\";\n\ttotal: number;\n\tfailed: Array<{\n\t\tname: string;\n\t\tconclusion: string | null;\n\t\turl: string | null;\n\t}>;\n}\n\nexport interface GitHubRelease {\n\tid: number;\n\ttag_name: string;\n\ttarget_commitish: string;\n\tdraft: boolean;\n\tprerelease: boolean;\n\thtml_url: string;\n\tassets: Array<{ name: string; url: string; browser_download_url: string }>;\n}\n\nexport function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile> {\n\tconst profiles = new Map<string, GitHubProfile>();\n\tfor (const [name, raw] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(value)?.profiles) ?? {},\n\t)) {\n\t\tconst config = asUnknownRecord(raw) ?? {};\n\t\tconst apiBaseUrl =\n\t\t\ttypeof config.api_base_url === \"string\"\n\t\t\t\t? config.api_base_url.replace(/\\/+$/, \"\")\n\t\t\t\t: \"https://api.github.com\";\n\t\tconst token = typeof config.token === \"string\" ? config.token.trim() : \"\";\n\t\tconst botLogin = typeof config.bot_login === \"string\" ? config.bot_login.trim() : \"leitwerk\";\n\t\tif (!/^https:\\/\\//.test(apiBaseUrl))\n\t\t\tthrow new Error(`GitHub profile '${name}' requires an HTTPS api_base_url`);\n\t\tif (!token) throw new Error(`GitHub profile '${name}' requires a token`);\n\t\tif (!botLogin) throw new Error(`GitHub profile '${name}' requires bot_login`);\n\t\tconst allowedOrganization = config.allowed_organization;\n\t\tif (\n\t\t\tallowedOrganization !== undefined &&\n\t\t\t(typeof allowedOrganization !== \"string\" || !/^[a-z0-9-]+$/i.test(allowedOrganization))\n\t\t) {\n\t\t\tthrow new Error(`GitHub profile '${name}' requires a valid allowed_organization`);\n\t\t}\n\t\tprofiles.set(name, {\n\t\t\tapiBaseUrl,\n\t\t\ttoken,\n\t\t\tbotLogin,\n\t\t\t...(typeof allowedOrganization === \"string\"\n\t\t\t\t? { allowedOrganization: allowedOrganization.toLowerCase() }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\treturn profiles;\n}\n\nexport function assertGitHubRepository(profile: GitHubProfile, owner: string, repo: string): void {\n\tif (\n\t\t!/^[a-z0-9-]+$/i.test(owner) ||\n\t\t!/^[a-z0-9_.-]+$/i.test(repo) ||\n\t\trepo === \".\" ||\n\t\trepo === \"..\"\n\t) {\n\t\tthrow new Error(\"Invalid GitHub repository\");\n\t}\n\tif (\n\t\tprofile.allowedOrganization &&\n\t\towner.toLowerCase() !== profile.allowedOrganization.toLowerCase()\n\t) {\n\t\tthrow new Error(`GitHub project must belong to ${profile.allowedOrganization}`);\n\t}\n}\n\nexport class GitHubClient extends RepositoryHttpClient {\n\tconstructor(readonly profile: GitHubProfile) {\n\t\tsuper(\"GitHub\", profile.apiBaseUrl, {\n\t\t\tAccept: \"application/vnd.github+json\",\n\t\t\tAuthorization: `Bearer ${profile.token}`,\n\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t});\n\t}\n\n\tprotected override response(path: string, init: RequestInit = {}): Promise<Response> {\n\t\treturn super.response(path, {\n\t\t\t...init,\n\t\t\tredirect: \"error\",\n\t\t\tsignal: init.signal ?? AbortSignal.timeout(30_000),\n\t\t});\n\t}\n\n\tprotected override repositoryPath(owner: string, repo: string): string {\n\t\tassertGitHubRepository(this.profile, owner, repo);\n\t\treturn super.repositoryPath(owner, repo);\n\t}\n\n\tasync listRepositories() {\n\t\treturn (\n\t\t\tawait this.pages<GitHubRepository>(\n\t\t\t\tthis.profile.allowedOrganization\n\t\t\t\t\t? `/orgs/${this.profile.allowedOrganization}/repos?type=all`\n\t\t\t\t\t: \"/user/repos?affiliation=owner,collaborator,organization_member\",\n\t\t\t)\n\t\t).filter(\n\t\t\t(repo) =>\n\t\t\t\t(!this.profile.allowedOrganization ||\n\t\t\t\t\trepo.owner.login.toLowerCase() === this.profile.allowedOrganization.toLowerCase()) &&\n\t\t\t\t!repo.archived &&\n\t\t\t\trepo.has_issues,\n\t\t);\n\t}\n\tasync listOpenIssues(owner: string, repo: string) {\n\t\treturn (\n\t\t\tawait this.pages<GitHubIssue & { pull_request?: unknown }>(\n\t\t\t\t`${this.repositoryPath(owner, repo)}/issues?state=open`,\n\t\t\t)\n\t\t).filter((issue) => !issue.pull_request);\n\t}\n\tlistIssueEvents(owner: string, repo: string, number: number) {\n\t\treturn this.pages<GitHubLabelEvent>(\n\t\t\t`${this.repositoryPath(owner, repo)}/issues/${number}/events`,\n\t\t);\n\t}\n\tasync isOrganizationMember(login: string): Promise<boolean> {\n\t\tif (!this.profile.allowedOrganization) return true;\n\t\tif (!/^[a-z0-9-]+$/i.test(login)) return false;\n\t\ttry {\n\t\t\tconst response = await this.response(\n\t\t\t\t`/orgs/${this.profile.allowedOrganization}/members/${encodeURIComponent(login)}`,\n\t\t\t);\n\t\t\treturn response.status === 204;\n\t\t} catch (error) {\n\t\t\tif (error instanceof IntegrationHttpError) {\n\t\t\t\tif (error.status === 404) return false;\n\t\t\t\tthrow new Error(`GitHub membership check failed with ${error.status}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync authorizedTrigger(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\ttrigger: string,\n\t\tdone: string,\n\t) {\n\t\treturn authorizedTrigger(this, owner, repo, number, trigger, done);\n\t}\n\tasync resolveGitIdentity(profile: string): Promise<GitHubGitIdentity> {\n\t\tconst user = await this.request<{ login: string; name: string | null; id: number }>(\"/user\");\n\t\tif (user.login !== this.profile.botLogin)\n\t\t\tthrow new Error(\"GitHub authenticated user does not match bot_login\");\n\t\treturn {\n\t\t\tprovider: \"github\",\n\t\t\tprofile,\n\t\t\tlogin: user.login,\n\t\t\tname: user.name || user.login,\n\t\t\temail: `${user.id}+${user.login}@users.noreply.github.com`,\n\t\t};\n\t}\n\tupdateIssue(owner: string, repo: string, number: number, patch: Record<string, unknown>) {\n\t\treturn this.request<GitHubIssue>(`${this.repositoryPath(owner, repo)}/issues/${number}`, {\n\t\t\tmethod: \"PATCH\",\n\t\t\tbody: JSON.stringify(patch),\n\t\t});\n\t}\n\tasync ensureLabel(owner: string, repo: string, name: string) {\n\t\tconst labels = await this.pages<{ id: number; name: string }>(\n\t\t\t`${this.repositoryPath(owner, repo)}/labels`,\n\t\t);\n\t\treturn (\n\t\t\tlabels.find((label) => label.name === name) ??\n\t\t\tthis.request<{ id: number; name: string }>(`${this.repositoryPath(owner, repo)}/labels`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: JSON.stringify({ name, color: \"238636\" }),\n\t\t\t})\n\t\t);\n\t}\n\taddFeedbackReaction(owner: string, repo: string, kind: string, id: number) {\n\t\tconst segment = kind === \"inline\" ? \"pulls/comments\" : \"issues/comments\";\n\t\treturn this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ content: \"eyes\" }),\n\t\t});\n\t}\n\tasync replyFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tpr: number,\n\t\tkind: string,\n\t\tid: number,\n\t\tbody: string,\n\t) {\n\t\tif (kind === \"inline\")\n\t\t\treturn this.request(\n\t\t\t\t`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: JSON.stringify({ body }),\n\t\t\t\t},\n\t\t\t);\n\t\treturn this.addIssueComment(owner, repo, pr, body);\n\t}\n\n\tgetCommit(owner: string, repo: string, ref: string) {\n\t\treturn this.request<{ sha: string }>(\n\t\t\t`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`,\n\t\t);\n\t}\n\n\tasync isAncestor(owner: string, repo: string, ancestor: string, descendant: string) {\n\t\tconst comparison = await this.request<{ status: string }>(\n\t\t\t`${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`,\n\t\t);\n\t\treturn comparison.status === \"identical\" || comparison.status === \"ahead\";\n\t}\n\n\tasync listPullRequestFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitHubFeedbackItem[]> {\n\t\tconst prefix = `${this.repositoryPath(owner, repo)}`;\n\t\tconst [conversation, reviews, inline] = await Promise.all([\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/issues/${number}/comments`, signal),\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/pulls/${number}/reviews`, signal),\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/pulls/${number}/comments`, signal),\n\t\t]);\n\n\t\tconst candidates = [\n\t\t\t...conversation.map((item) => ({ kind: \"conversation\" as const, item })),\n\t\t\t...reviews.map((item) => ({ kind: \"review\" as const, item })),\n\t\t\t...inline.map((item) => ({ kind: \"inline\" as const, item })),\n\t\t];\n\t\tconst feedback: GitHubFeedbackItem[] = [];\n\t\tconst needsProvenance: typeof candidates = [];\n\t\tfor (const candidate of candidates) {\n\t\t\tconst { kind, item } = candidate;\n\t\t\tconst normalized = normalize(kind, item);\n\t\t\tif (!normalized) continue;\n\t\t\tconst createdAt = typeof item.created_at === \"string\" ? Date.parse(item.created_at) : NaN;\n\t\t\tconst updatedAt = typeof item.updated_at === \"string\" ? Date.parse(item.updated_at) : NaN;\n\t\t\tif (\n\t\t\t\t!this.profile.allowedOrganization ||\n\t\t\t\t(kind !== \"review\" && Number.isFinite(createdAt) && createdAt === updatedAt)\n\t\t\t) {\n\t\t\t\tfeedback.push(normalized);\n\t\t\t} else if (typeof item.node_id === \"string\" && item.node_id) {\n\t\t\t\t// REST attributes edited bodies to their original author. Reviews also\n\t\t\t\t// omit edit timestamps, so obtain the body and latest editor together.\n\t\t\t\tneedsProvenance.push(candidate);\n\t\t\t}\n\t\t}\n\t\tfor (let offset = 0; offset < needsProvenance.length; offset += 100) {\n\t\t\tconst batch = needsProvenance.slice(offset, offset + 100);\n\t\t\tconst response = await this.request<{\n\t\t\t\tdata?: { nodes?: Array<Record<string, unknown> | null> };\n\t\t\t\terrors?: unknown[];\n\t\t\t}>(\"/graphql\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tsignal,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tquery: `query LeitwerkFeedbackProvenance($ids: [ID!]!) {\n\t\t\t\t\t\tnodes(ids: $ids) {\n\t\t\t\t\t\t\tid __typename\n\t\t\t\t\t\t\t... on IssueComment { body createdAt lastEditedAt author { login } editor { login } }\n\t\t\t\t\t\t\t... on PullRequestReview { body createdAt submittedAt lastEditedAt author { login } editor { login } }\n\t\t\t\t\t\t\t... on PullRequestReviewComment { body createdAt lastEditedAt author { login } editor { login } path line }\n\t\t\t\t\t\t}\n\t\t\t\t\t}`,\n\t\t\t\t\tvariables: { ids: batch.map(({ item }) => item.node_id) },\n\t\t\t\t}),\n\t\t\t});\n\t\t\tif (response.errors?.length || !Array.isArray(response.data?.nodes)) {\n\t\t\t\tthrow new Error(\"GitHub feedback provenance lookup failed\");\n\t\t\t}\n\t\t\tconst snapshots = new Map(\n\t\t\t\tresponse.data.nodes.filter((node) => node !== null).map((node) => [node.id, node]),\n\t\t\t);\n\t\t\tfor (const { kind, item } of batch) {\n\t\t\t\tconst snapshot = snapshots.get(item.node_id);\n\t\t\t\tconst expectedType = {\n\t\t\t\t\tconversation: \"IssueComment\",\n\t\t\t\t\treview: \"PullRequestReview\",\n\t\t\t\t\tinline: \"PullRequestReviewComment\",\n\t\t\t\t}[kind];\n\t\t\t\tif (!snapshot || snapshot.__typename !== expectedType) continue;\n\t\t\t\tconst publishedAt = kind === \"review\" ? snapshot.submittedAt : snapshot.createdAt;\n\t\t\t\tif (typeof publishedAt !== \"string\" || !Number.isFinite(Date.parse(publishedAt))) continue;\n\t\t\t\tconst editedAt = snapshot.lastEditedAt;\n\t\t\t\tif (editedAt !== null) {\n\t\t\t\t\tif (typeof editedAt !== \"string\" || !Number.isFinite(Date.parse(editedAt))) continue;\n\t\t\t\t\tconst editor = asUnknownRecord(snapshot.editor)?.login;\n\t\t\t\t\tif (typeof editor !== \"string\" || !(await this.isOrganizationMember(editor))) continue;\n\t\t\t\t}\n\t\t\t\tconst normalized = normalize(kind, {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tid: item.id,\n\t\t\t\t\tuser: snapshot.author,\n\t\t\t\t\tcreated_at: editedAt ?? publishedAt,\n\t\t\t\t});\n\t\t\t\tif (normalized) feedback.push(normalized);\n\t\t\t}\n\t\t}\n\t\treturn feedback;\n\t}\n\n\tasync getCheckSummary(owner: string, repo: string, headSha: string): Promise<GitHubCheckSummary> {\n\t\tconst runs: Array<Record<string, unknown>> = [];\n\t\tfor (let page = 1; ; page++) {\n\t\t\tconst response = await this.request<{ check_runs: Array<Record<string, unknown>> }>(\n\t\t\t\t`${this.repositoryPath(owner, repo)}/commits/${headSha}/check-runs?per_page=100&page=${page}`,\n\t\t\t);\n\t\t\truns.push(...response.check_runs);\n\t\t\tif (response.check_runs.length < 100) break;\n\t\t}\n\t\tconst terminalSuccess = new Set([\"success\", \"neutral\", \"skipped\"]);\n\t\tconst failed = runs\n\t\t\t.filter((run) => run.status === \"completed\" && !terminalSuccess.has(String(run.conclusion)))\n\t\t\t.map((run) => ({\n\t\t\t\tname: String(run.name ?? \"unknown\"),\n\t\t\t\tconclusion: typeof run.conclusion === \"string\" ? run.conclusion : null,\n\t\t\t\turl: typeof run.html_url === \"string\" ? run.html_url : null,\n\t\t\t}));\n\t\tconst pending = runs.some((run) => run.status !== \"completed\");\n\t\treturn {\n\t\t\theadSha,\n\t\t\tstatus: failed.length ? \"failure\" : pending || !runs.length ? \"pending\" : \"success\",\n\t\t\ttotal: runs.length,\n\t\t\tfailed,\n\t\t};\n\t}\n\n\t/** Human feedback checked against current membership; delivery receipts use raw reads. */\n\tasync listActionablePullRequestFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\treturn actionableFeedback(\n\t\t\tthis,\n\t\t\tawait this.listPullRequestFeedback(owner, repo, number, signal),\n\t\t);\n\t}\n\n\tlistFeedbackReplies(owner: string, repo: string, pr: number, kind: string) {\n\t\treturn kind === \"inline\"\n\t\t\t? this.pages<Record<string, unknown>>(\n\t\t\t\t\t`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments`,\n\t\t\t\t)\n\t\t\t: this.listIssueComments(owner, repo, pr);\n\t}\n\n\tlistFeedbackReactions(owner: string, repo: string, kind: string, id: number) {\n\t\tif (kind !== \"inline\" && kind !== \"conversation\")\n\t\t\tthrow new Error(\"Reviews do not support reactions\");\n\t\tconst segment = kind === \"inline\" ? \"pulls/comments\" : \"issues/comments\";\n\t\treturn this.pages<{ id: number; content: string; user: { login: string } }>(\n\t\t\t`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`,\n\t\t);\n\t}\n\n\tlistReleases(owner: string, repo: string) {\n\t\treturn this.pages<GitHubRelease>(`${this.repositoryPath(owner, repo)}/releases`);\n\t}\n\n\tdownloadReleaseAsset(asset: GitHubRelease[\"assets\"][number]): Promise<string> {\n\t\tconst url = new URL(asset.url);\n\t\tif (`${url.protocol}//${url.host}` !== this.profile.apiBaseUrl)\n\t\t\tthrow new Error(\"GitHub release asset URL does not match the configured API origin\");\n\t\treturn this.response(`${url.pathname}${url.search}`, {\n\t\t\theaders: { Accept: \"application/octet-stream\" },\n\t\t}).then((response) => response.text());\n\t}\n}\n"],"mappings":";AAIA,eAAsB,kBACrB,QACA,OACA,MACA,QACA,SACA,MACC;AACD,MACC,OAAO,QAAQ,uBACf,MAAM,YAAY,MAAM,OAAO,QAAQ,oBAAoB,YAAY;AAEvE,WAAO;AACR,QAAM,QAAS,MAAM,OAAO,SAAS,OAAO,MAAM,MAAM;AAGxD,MACC,MAAM,gBACN,MAAM,UAAU,UAChB,CAAC,MAAM,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS,OAAO,KACpD,MAAM,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS,IAAI;AAEhD,WAAO;AACR,QAAM,QAAQ,MAAM,OAAO,gBAAgB,OAAO,MAAM,MAAM,GAC5D;AAAA,IACA,CAAC,WACC,MAAM,UAAU,aAAa,MAAM,UAAU,gBAAgB,MAAM,OAAO,SAAS;AAAA,EACtF,EACC,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAC/B,MACC,MAAM,UAAU,aAChB,CAAC,KAAK,OAAO,SACb,CAAE,MAAM,OAAO,qBAAqB,KAAK,MAAM,KAAK;AAEpD,WAAO;AACR,SAAO,EAAE,OAAO,OAAO,KAAK,MAAM,OAAO,SAAS,KAAK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