@leitwerk-dev/github 0.0.0-bootstrap.0 → 0.2.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 +113 -1
- package/dist/LICENSE +13 -0
- package/dist/authorization.d.ts +12 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/binding.d.ts +4 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/capability.d.ts +8 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/chunk-PVE52UFH.js +318 -0
- package/dist/chunk-PVE52UFH.js.map +1 -0
- package/dist/client.d.ts +111 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/external.d.ts +85 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +809 -0
- package/dist/index.js.map +1 -0
- package/dist/issue-provider.d.ts +8 -0
- package/dist/issue-provider.d.ts.map +1 -0
- package/dist/issue-watcher.d.ts +19 -0
- package/dist/issue-watcher.d.ts.map +1 -0
- package/dist/poll-report.d.ts +22 -0
- package/dist/poll-report.d.ts.map +1 -0
- package/dist/provider.d.ts +6 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/testing.d.ts +81 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +297 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/package.json +55 -14
- package/src/authorization.ts +54 -0
- package/src/binding.ts +6 -0
- package/src/capability.ts +13 -0
- package/src/client.ts +421 -0
- package/src/external.ts +139 -0
- package/src/index.ts +45 -0
- package/src/issue-provider.ts +278 -0
- package/src/issue-watcher.ts +30 -0
- package/src/poll-report.ts +47 -0
- package/src/provider.ts +216 -0
- package/src/testing.ts +384 -0
- package/src/tools.ts +304 -0
package/README.md
CHANGED
|
@@ -1 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
# GitHub integration
|
|
2
|
+
|
|
3
|
+
Server-owned GitHub API profiles, pull-request state polling, and project-scoped
|
|
4
|
+
LLM tools. Tokens never enter workers. Reads cover issues, pull requests, reviews,
|
|
5
|
+
inline comments, Actions check runs, and releases. Pull-request creation, comments,
|
|
6
|
+
and updates use the durable external-write log.
|
|
7
|
+
|
|
8
|
+
```yaml
|
|
9
|
+
extensions:
|
|
10
|
+
github:
|
|
11
|
+
profiles:
|
|
12
|
+
primary:
|
|
13
|
+
api_base_url: https://api.github.com
|
|
14
|
+
token: "..."
|
|
15
|
+
bot_login: leitwerk-bot
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The token needs repository contents and pull-request read/write access, issue
|
|
19
|
+
read/write access when issue tools are used, and Actions/checks read access. Git
|
|
20
|
+
checkout credentials are configured separately through `git-ssh`.
|
|
21
|
+
|
|
22
|
+
## Explicit integration composition
|
|
23
|
+
|
|
24
|
+
`GitHubClientLike` and `setupGitHubIntegration` let local compositions supply a
|
|
25
|
+
client while retaining shared tools and watchers. The optional provider clock
|
|
26
|
+
changes polling eligibility; it does not bypass event correlation.
|
|
27
|
+
|
|
28
|
+
Check observations record pending, success, and failure independently of event firing filters. Each observation names its revision; failed checks include names and run links. Refresh failures retain the last successful observation. Delayed writes carry the captured subscription generation. Existing firing filters and deduplication remain unchanged.
|
|
29
|
+
|
|
30
|
+
## Merge conflicts and outdated bases
|
|
31
|
+
|
|
32
|
+
Fresh pull-request metadata is polled every 30 seconds. Confirmed conflicts
|
|
33
|
+
(`mergeable: false`, `mergeable_state: dirty`) and clean but outdated branches
|
|
34
|
+
(`mergeable: true`, `mergeable_state: behind`) trigger the existing rebase flow.
|
|
35
|
+
The trigger uses GitHub’s merge eligibility state, not commit divergence: a PR
|
|
36
|
+
that the UI allows to merge (`clean`, `unstable`, or `has_hooks`) is left alone.
|
|
37
|
+
Behind evidence carries `reason: behind` and refreshes the base branch SHA because
|
|
38
|
+
GitHub’s PR base SHA can lag the current branch. Unknown or missing mergeability
|
|
39
|
+
is retried; blocked states and failing checks alone do not trigger a rebase.
|
|
40
|
+
Polling does not depend on checks or feedback API calls.
|
|
41
|
+
Evidence includes repository, PR, both branch names, head SHA, base SHA, and PR link.
|
|
42
|
+
Observations show both revisions and refresh errors. Before firing, the provider
|
|
43
|
+
rechecks the subscription generation and resolved configuration. Events deduplicate
|
|
44
|
+
by repository, PR, head, and base, so a new base can trigger with an unchanged head.
|
|
45
|
+
The process persists its last accepted key and validates evidence on consumption.
|
|
46
|
+
|
|
47
|
+
## Project binding
|
|
48
|
+
|
|
49
|
+
Server launch code writes a non-secret `metadata.github` object containing
|
|
50
|
+
`{ owner, repo, profile }` on each process project. Tools use only the project
|
|
51
|
+
selected and authorized by the server, never repository/profile tool arguments.
|
|
52
|
+
`GitHubProjectBinding` and `resolveGitHubProjectBinding` expose this contract.
|
|
53
|
+
Different projects in one process may use different profiles. Credentials remain
|
|
54
|
+
in the server integration; bindings contain only a profile identifier.
|
|
55
|
+
|
|
56
|
+
Legacy stored metadata can read its profile from `githubProfile` in process parameters.
|
|
57
|
+
Malformed explicit values fail instead of selecting another profile.
|
|
58
|
+
Capability, watcher, external-source and write identifiers retain their original
|
|
59
|
+
strings, including historical `@leitwerk-private/` prefixes. Package names do not
|
|
60
|
+
rename durable protocol identities.
|
|
61
|
+
|
|
62
|
+
## Local adapter
|
|
63
|
+
|
|
64
|
+
Import `LocalGitHubAdapter` from `@leitwerk-dev/github/testing` and supply its
|
|
65
|
+
`client()` through `setupGitHubIntegration`. Construct the adapter with an owned
|
|
66
|
+
`root` directory, a local `baseUrl`, and an optional `now` clock. Provider state
|
|
67
|
+
persists in `github.json`; unknown resources fail locally. Production registration
|
|
68
|
+
does not import this entrypoint. The adapter never falls back to HTTP.
|
|
69
|
+
|
|
70
|
+
`seed({ owner, name, files, defaultBranch })` creates or reuses real local Git
|
|
71
|
+
repositories. Reads refresh open PR heads, bases and mergeability. `merge` updates
|
|
72
|
+
the base with a fast-forward or real merge commit and rejects conflicts.
|
|
73
|
+
`addFeedback` accepts conversation, review and inline feedback.
|
|
74
|
+
|
|
75
|
+
`setChecks` records checks for a specific commit. A new PR head has pending checks
|
|
76
|
+
until that revision receives results. `publishRelease` takes a tag, commit ref and
|
|
77
|
+
an asset-name/content map; it verifies real ancestry through Git. Set
|
|
78
|
+
`state.failAfterPullRequestWrite` to simulate a lost PR-create response.
|
|
79
|
+
|
|
80
|
+
The integration exposes general release, asset and ancestry operations through
|
|
81
|
+
its server-owned client. Applications own asset selection and release-lock policy.
|
|
82
|
+
|
|
83
|
+
## Organization issue workflows
|
|
84
|
+
|
|
85
|
+
Set optional `allowed_organization: leitwerk-dev` on a profile to confine all
|
|
86
|
+
repository tools and client operations to that organization. Omitted restrictions
|
|
87
|
+
retain unrestricted profiles. Restricted tokens also need organization membership
|
|
88
|
+
read access. Discovery lists enabled organization repositories and checks the
|
|
89
|
+
latest trigger-label actor's current membership. A launch preparation check
|
|
90
|
+
rechecks the actor and label event after repository/identity preparation.
|
|
91
|
+
|
|
92
|
+
`githubIssueWatcherSource` retains `@leitwerk-public/github.issue`.
|
|
93
|
+
`githubExternal.checks`, `pullRequestFeedback`, `pullRequestTerminal` and
|
|
94
|
+
`issueCancelled` retain their separate `@leitwerk-public/github.*` contracts.
|
|
95
|
+
Feedback has independent conversation, review and inline cursors and a two-minute
|
|
96
|
+
default quiet period. Restricted actionable feedback requires a current member
|
|
97
|
+
author; edited bodies also require verified current editor membership from the
|
|
98
|
+
same GraphQL snapshot as the body. Bot delivery markers are excluded.
|
|
99
|
+
|
|
100
|
+
Terminal PR reconciliation takes precedence over source issue cancellation.
|
|
101
|
+
Checks correlate the captured head with a refreshed PR. Both observations and
|
|
102
|
+
events reject superseded subscriptions; generation-bound events are never queued
|
|
103
|
+
for a later subscription. The existing combined PR-state interface remains available.
|
|
104
|
+
|
|
105
|
+
Delivery tools preserve write identities and reconciliation markers across
|
|
106
|
+
restarts. Comment/reply reconciliation uses unfiltered receipt reads, so
|
|
107
|
+
membership changes cannot conceal a completed write. Reactions reconcile the bot's
|
|
108
|
+
existing eyes reaction. Issue finalization reconciles the desired patch before
|
|
109
|
+
retrying it. Release-lock selection stays outside this integration.
|
|
110
|
+
|
|
111
|
+
The local adapter supports `createIssue`, `setIssueLabel`, `setMembership`,
|
|
112
|
+
`editFeedback` and `failNextResponse`. Membership, label events, feedback edits,
|
|
113
|
+
write outcomes and Git history survive restart.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GitHubClient, GitHubFeedbackItem, GitHubIssue } from "./client.js";
|
|
2
|
+
type MembershipClient = Pick<GitHubClient, "profile" | "isOrganizationMember">;
|
|
3
|
+
export declare function authorizedTrigger(client: MembershipClient & Pick<GitHubClient, "getIssue" | "listIssueEvents">, owner: string, repo: string, number: number, trigger: string, done: string): Promise<{
|
|
4
|
+
issue: GitHubIssue & {
|
|
5
|
+
pull_request?: unknown;
|
|
6
|
+
};
|
|
7
|
+
actor: string;
|
|
8
|
+
eventId: number;
|
|
9
|
+
} | null>;
|
|
10
|
+
export declare function actionableFeedback(client: MembershipClient, feedback: GitHubFeedbackItem[]): Promise<GitHubFeedbackItem[]>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,sBAAsB,CAAC,CAAC;AAE/E,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC7E,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;;uBAQI,OAAO;;;;UAsBvB;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iCAWhG"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export type { RepositoryProjectBinding as GitHubProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
export declare const resolveGitHubProjectBinding: (ctx: Parameters<typeof resolveRepositoryProjectBinding>[0]) => import("@leitwerk-dev/process-sdk").RepositoryProjectBinding;
|
|
4
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,YAAY,EAAE,wBAAwB,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAClG,eAAO,MAAM,2BAA2B,GACvC,KAAK,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,iEACR,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GitHubClient } from "./client.js";
|
|
2
|
+
/** Public contract shared by HTTP and local adapters. */
|
|
3
|
+
export type GitHubClientLike = Pick<GitHubClient, keyof GitHubClient>;
|
|
4
|
+
export interface GitHubIntegration {
|
|
5
|
+
client(profile: string): GitHubClientLike;
|
|
6
|
+
}
|
|
7
|
+
export declare const githubIntegration: import("@leitwerk-dev/process-sdk").CapabilityToken<GitHubIntegration>;
|
|
8
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,YAAY,CAAC,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AAED,eAAO,MAAM,iBAAiB,wEAE7B,CAAC"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// src/authorization.ts
|
|
2
|
+
async function authorizedTrigger(client, owner, repo, number, trigger, done) {
|
|
3
|
+
if (client.profile.allowedOrganization && owner.toLowerCase() !== client.profile.allowedOrganization.toLowerCase())
|
|
4
|
+
return null;
|
|
5
|
+
const issue = await client.getIssue(owner, repo, number);
|
|
6
|
+
if (issue.pull_request || issue.state !== "open" || !issue.labels.some((label) => label.name === trigger) || issue.labels.some((label) => label.name === done))
|
|
7
|
+
return null;
|
|
8
|
+
const last = (await client.listIssueEvents(owner, repo, number)).filter(
|
|
9
|
+
(event) => (event.event === "labeled" || event.event === "unlabeled") && event.label?.name === trigger
|
|
10
|
+
).sort((a, b) => b.id - a.id)[0];
|
|
11
|
+
if (last?.event !== "labeled" || !last.actor?.login || !await client.isOrganizationMember(last.actor.login))
|
|
12
|
+
return null;
|
|
13
|
+
return { issue, actor: last.actor.login, eventId: last.id };
|
|
14
|
+
}
|
|
15
|
+
async function actionableFeedback(client, feedback) {
|
|
16
|
+
const authorized = [];
|
|
17
|
+
for (const item of feedback) {
|
|
18
|
+
if (item.author.toLowerCase() === client.profile.botLogin.toLowerCase() || item.body.includes("<!-- leitwerk-write:"))
|
|
19
|
+
continue;
|
|
20
|
+
if (await client.isOrganizationMember(item.author)) authorized.push(item);
|
|
21
|
+
}
|
|
22
|
+
return authorized;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/client.ts
|
|
26
|
+
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
27
|
+
import {
|
|
28
|
+
IntegrationHttpError,
|
|
29
|
+
normalizeRepositoryFeedback as normalize,
|
|
30
|
+
RepositoryHttpClient
|
|
31
|
+
} from "@leitwerk-dev/process-sdk";
|
|
32
|
+
function parseGitHubProfiles(value) {
|
|
33
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
34
|
+
for (const [name, raw] of Object.entries(
|
|
35
|
+
asUnknownRecord(asUnknownRecord(value)?.profiles) ?? {}
|
|
36
|
+
)) {
|
|
37
|
+
const config = asUnknownRecord(raw) ?? {};
|
|
38
|
+
const apiBaseUrl = typeof config.api_base_url === "string" ? config.api_base_url.replace(/\/+$/, "") : "https://api.github.com";
|
|
39
|
+
const token = typeof config.token === "string" ? config.token.trim() : "";
|
|
40
|
+
const botLogin = typeof config.bot_login === "string" ? config.bot_login.trim() : "leitwerk";
|
|
41
|
+
if (!/^https:\/\//.test(apiBaseUrl))
|
|
42
|
+
throw new Error(`GitHub profile '${name}' requires an HTTPS api_base_url`);
|
|
43
|
+
if (!token) throw new Error(`GitHub profile '${name}' requires a token`);
|
|
44
|
+
if (!botLogin) throw new Error(`GitHub profile '${name}' requires bot_login`);
|
|
45
|
+
const allowedOrganization = config.allowed_organization;
|
|
46
|
+
if (allowedOrganization !== void 0 && (typeof allowedOrganization !== "string" || !/^[a-z0-9-]+$/i.test(allowedOrganization))) {
|
|
47
|
+
throw new Error(`GitHub profile '${name}' requires a valid allowed_organization`);
|
|
48
|
+
}
|
|
49
|
+
profiles.set(name, {
|
|
50
|
+
apiBaseUrl,
|
|
51
|
+
token,
|
|
52
|
+
botLogin,
|
|
53
|
+
...typeof allowedOrganization === "string" ? { allowedOrganization: allowedOrganization.toLowerCase() } : {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return profiles;
|
|
57
|
+
}
|
|
58
|
+
function assertGitHubRepository(profile, owner, repo) {
|
|
59
|
+
if (!/^[a-z0-9-]+$/i.test(owner) || !/^[a-z0-9_.-]+$/i.test(repo) || repo === "." || repo === "..") {
|
|
60
|
+
throw new Error("Invalid GitHub repository");
|
|
61
|
+
}
|
|
62
|
+
if (profile.allowedOrganization && owner.toLowerCase() !== profile.allowedOrganization.toLowerCase()) {
|
|
63
|
+
throw new Error(`GitHub project must belong to ${profile.allowedOrganization}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var GitHubClient = class extends RepositoryHttpClient {
|
|
67
|
+
constructor(profile) {
|
|
68
|
+
super("GitHub", profile.apiBaseUrl, {
|
|
69
|
+
Accept: "application/vnd.github+json",
|
|
70
|
+
Authorization: `Bearer ${profile.token}`,
|
|
71
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
72
|
+
});
|
|
73
|
+
this.profile = profile;
|
|
74
|
+
}
|
|
75
|
+
profile;
|
|
76
|
+
response(path, init = {}) {
|
|
77
|
+
return super.response(path, {
|
|
78
|
+
...init,
|
|
79
|
+
redirect: "error",
|
|
80
|
+
signal: init.signal ?? AbortSignal.timeout(3e4)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
repositoryPath(owner, repo) {
|
|
84
|
+
assertGitHubRepository(this.profile, owner, repo);
|
|
85
|
+
return super.repositoryPath(owner, repo);
|
|
86
|
+
}
|
|
87
|
+
async listRepositories() {
|
|
88
|
+
return (await this.pages(
|
|
89
|
+
this.profile.allowedOrganization ? `/orgs/${this.profile.allowedOrganization}/repos?type=all` : "/user/repos?affiliation=owner,collaborator,organization_member"
|
|
90
|
+
)).filter(
|
|
91
|
+
(repo) => (!this.profile.allowedOrganization || repo.owner.login.toLowerCase() === this.profile.allowedOrganization.toLowerCase()) && !repo.archived && repo.has_issues
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
async listOpenIssues(owner, repo) {
|
|
95
|
+
return (await this.pages(
|
|
96
|
+
`${this.repositoryPath(owner, repo)}/issues?state=open`
|
|
97
|
+
)).filter((issue) => !issue.pull_request);
|
|
98
|
+
}
|
|
99
|
+
listIssueEvents(owner, repo, number) {
|
|
100
|
+
return this.pages(
|
|
101
|
+
`${this.repositoryPath(owner, repo)}/issues/${number}/events`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
async isOrganizationMember(login) {
|
|
105
|
+
if (!this.profile.allowedOrganization) return true;
|
|
106
|
+
if (!/^[a-z0-9-]+$/i.test(login)) return false;
|
|
107
|
+
try {
|
|
108
|
+
const response = await this.response(
|
|
109
|
+
`/orgs/${this.profile.allowedOrganization}/members/${encodeURIComponent(login)}`
|
|
110
|
+
);
|
|
111
|
+
return response.status === 204;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof IntegrationHttpError) {
|
|
114
|
+
if (error.status === 404) return false;
|
|
115
|
+
throw new Error(`GitHub membership check failed with ${error.status}`);
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async authorizedTrigger(owner, repo, number, trigger, done) {
|
|
121
|
+
return authorizedTrigger(this, owner, repo, number, trigger, done);
|
|
122
|
+
}
|
|
123
|
+
async resolveGitIdentity(profile) {
|
|
124
|
+
const user = await this.request("/user");
|
|
125
|
+
if (user.login !== this.profile.botLogin)
|
|
126
|
+
throw new Error("GitHub authenticated user does not match bot_login");
|
|
127
|
+
return {
|
|
128
|
+
provider: "github",
|
|
129
|
+
profile,
|
|
130
|
+
login: user.login,
|
|
131
|
+
name: user.name || user.login,
|
|
132
|
+
email: `${user.id}+${user.login}@users.noreply.github.com`
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
updateIssue(owner, repo, number, patch) {
|
|
136
|
+
return this.request(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
|
|
137
|
+
method: "PATCH",
|
|
138
|
+
body: JSON.stringify(patch)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async ensureLabel(owner, repo, name) {
|
|
142
|
+
const labels = await this.pages(
|
|
143
|
+
`${this.repositoryPath(owner, repo)}/labels`
|
|
144
|
+
);
|
|
145
|
+
return labels.find((label) => label.name === name) ?? this.request(`${this.repositoryPath(owner, repo)}/labels`, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
body: JSON.stringify({ name, color: "238636" })
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
addFeedbackReaction(owner, repo, kind, id) {
|
|
151
|
+
const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
|
|
152
|
+
return this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
body: JSON.stringify({ content: "eyes" })
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async replyFeedback(owner, repo, pr, kind, id, body) {
|
|
158
|
+
if (kind === "inline")
|
|
159
|
+
return this.request(
|
|
160
|
+
`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,
|
|
161
|
+
{
|
|
162
|
+
method: "POST",
|
|
163
|
+
body: JSON.stringify({ body })
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
return this.addIssueComment(owner, repo, pr, body);
|
|
167
|
+
}
|
|
168
|
+
getCommit(owner, repo, ref) {
|
|
169
|
+
return this.request(
|
|
170
|
+
`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
async isAncestor(owner, repo, ancestor, descendant) {
|
|
174
|
+
const comparison = await this.request(
|
|
175
|
+
`${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`
|
|
176
|
+
);
|
|
177
|
+
return comparison.status === "identical" || comparison.status === "ahead";
|
|
178
|
+
}
|
|
179
|
+
async listPullRequestFeedback(owner, repo, number, signal) {
|
|
180
|
+
const prefix = `${this.repositoryPath(owner, repo)}`;
|
|
181
|
+
const [conversation, reviews, inline] = await Promise.all([
|
|
182
|
+
this.pages(`${prefix}/issues/${number}/comments`, signal),
|
|
183
|
+
this.pages(`${prefix}/pulls/${number}/reviews`, signal),
|
|
184
|
+
this.pages(`${prefix}/pulls/${number}/comments`, signal)
|
|
185
|
+
]);
|
|
186
|
+
const candidates = [
|
|
187
|
+
...conversation.map((item) => ({ kind: "conversation", item })),
|
|
188
|
+
...reviews.map((item) => ({ kind: "review", item })),
|
|
189
|
+
...inline.map((item) => ({ kind: "inline", item }))
|
|
190
|
+
];
|
|
191
|
+
const feedback = [];
|
|
192
|
+
const needsProvenance = [];
|
|
193
|
+
for (const candidate of candidates) {
|
|
194
|
+
const { kind, item } = candidate;
|
|
195
|
+
const normalized = normalize(kind, item);
|
|
196
|
+
if (!normalized) continue;
|
|
197
|
+
const createdAt = typeof item.created_at === "string" ? Date.parse(item.created_at) : NaN;
|
|
198
|
+
const updatedAt = typeof item.updated_at === "string" ? Date.parse(item.updated_at) : NaN;
|
|
199
|
+
if (!this.profile.allowedOrganization || kind !== "review" && Number.isFinite(createdAt) && createdAt === updatedAt) {
|
|
200
|
+
feedback.push(normalized);
|
|
201
|
+
} else if (typeof item.node_id === "string" && item.node_id) {
|
|
202
|
+
needsProvenance.push(candidate);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
for (let offset = 0; offset < needsProvenance.length; offset += 100) {
|
|
206
|
+
const batch = needsProvenance.slice(offset, offset + 100);
|
|
207
|
+
const response = await this.request("/graphql", {
|
|
208
|
+
method: "POST",
|
|
209
|
+
signal,
|
|
210
|
+
body: JSON.stringify({
|
|
211
|
+
query: `query LeitwerkFeedbackProvenance($ids: [ID!]!) {
|
|
212
|
+
nodes(ids: $ids) {
|
|
213
|
+
id __typename
|
|
214
|
+
... on IssueComment { body createdAt lastEditedAt author { login } editor { login } }
|
|
215
|
+
... on PullRequestReview { body createdAt submittedAt lastEditedAt author { login } editor { login } }
|
|
216
|
+
... on PullRequestReviewComment { body createdAt lastEditedAt author { login } editor { login } path line }
|
|
217
|
+
}
|
|
218
|
+
}`,
|
|
219
|
+
variables: { ids: batch.map(({ item }) => item.node_id) }
|
|
220
|
+
})
|
|
221
|
+
});
|
|
222
|
+
if (response.errors?.length || !Array.isArray(response.data?.nodes)) {
|
|
223
|
+
throw new Error("GitHub feedback provenance lookup failed");
|
|
224
|
+
}
|
|
225
|
+
const snapshots = new Map(
|
|
226
|
+
response.data.nodes.filter((node) => node !== null).map((node) => [node.id, node])
|
|
227
|
+
);
|
|
228
|
+
for (const { kind, item } of batch) {
|
|
229
|
+
const snapshot = snapshots.get(item.node_id);
|
|
230
|
+
const expectedType = {
|
|
231
|
+
conversation: "IssueComment",
|
|
232
|
+
review: "PullRequestReview",
|
|
233
|
+
inline: "PullRequestReviewComment"
|
|
234
|
+
}[kind];
|
|
235
|
+
if (!snapshot || snapshot.__typename !== expectedType) continue;
|
|
236
|
+
const publishedAt = kind === "review" ? snapshot.submittedAt : snapshot.createdAt;
|
|
237
|
+
if (typeof publishedAt !== "string" || !Number.isFinite(Date.parse(publishedAt))) continue;
|
|
238
|
+
const editedAt = snapshot.lastEditedAt;
|
|
239
|
+
if (editedAt !== null) {
|
|
240
|
+
if (typeof editedAt !== "string" || !Number.isFinite(Date.parse(editedAt))) continue;
|
|
241
|
+
const editor = asUnknownRecord(snapshot.editor)?.login;
|
|
242
|
+
if (typeof editor !== "string" || !await this.isOrganizationMember(editor)) continue;
|
|
243
|
+
}
|
|
244
|
+
const normalized = normalize(kind, {
|
|
245
|
+
...snapshot,
|
|
246
|
+
id: item.id,
|
|
247
|
+
user: snapshot.author,
|
|
248
|
+
created_at: editedAt ?? publishedAt
|
|
249
|
+
});
|
|
250
|
+
if (normalized) feedback.push(normalized);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return feedback;
|
|
254
|
+
}
|
|
255
|
+
async getCheckSummary(owner, repo, headSha) {
|
|
256
|
+
const runs = [];
|
|
257
|
+
for (let page = 1; ; page++) {
|
|
258
|
+
const response = await this.request(
|
|
259
|
+
`${this.repositoryPath(owner, repo)}/commits/${headSha}/check-runs?per_page=100&page=${page}`
|
|
260
|
+
);
|
|
261
|
+
runs.push(...response.check_runs);
|
|
262
|
+
if (response.check_runs.length < 100) break;
|
|
263
|
+
}
|
|
264
|
+
const terminalSuccess = /* @__PURE__ */ new Set(["success", "neutral", "skipped"]);
|
|
265
|
+
const failed = runs.filter((run) => run.status === "completed" && !terminalSuccess.has(String(run.conclusion))).map((run) => ({
|
|
266
|
+
name: String(run.name ?? "unknown"),
|
|
267
|
+
conclusion: typeof run.conclusion === "string" ? run.conclusion : null,
|
|
268
|
+
url: typeof run.html_url === "string" ? run.html_url : null
|
|
269
|
+
}));
|
|
270
|
+
const pending = runs.some((run) => run.status !== "completed");
|
|
271
|
+
return {
|
|
272
|
+
headSha,
|
|
273
|
+
status: failed.length ? "failure" : pending || !runs.length ? "pending" : "success",
|
|
274
|
+
total: runs.length,
|
|
275
|
+
failed
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/** Human feedback checked against current membership; delivery receipts use raw reads. */
|
|
279
|
+
async listActionablePullRequestFeedback(owner, repo, number, signal) {
|
|
280
|
+
return actionableFeedback(
|
|
281
|
+
this,
|
|
282
|
+
await this.listPullRequestFeedback(owner, repo, number, signal)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
listFeedbackReplies(owner, repo, pr, kind) {
|
|
286
|
+
return kind === "inline" ? this.pages(
|
|
287
|
+
`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments`
|
|
288
|
+
) : this.listIssueComments(owner, repo, pr);
|
|
289
|
+
}
|
|
290
|
+
listFeedbackReactions(owner, repo, kind, id) {
|
|
291
|
+
if (kind !== "inline" && kind !== "conversation")
|
|
292
|
+
throw new Error("Reviews do not support reactions");
|
|
293
|
+
const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
|
|
294
|
+
return this.pages(
|
|
295
|
+
`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
listReleases(owner, repo) {
|
|
299
|
+
return this.pages(`${this.repositoryPath(owner, repo)}/releases`);
|
|
300
|
+
}
|
|
301
|
+
downloadReleaseAsset(asset) {
|
|
302
|
+
const url = new URL(asset.url);
|
|
303
|
+
if (`${url.protocol}//${url.host}` !== this.profile.apiBaseUrl)
|
|
304
|
+
throw new Error("GitHub release asset URL does not match the configured API origin");
|
|
305
|
+
return this.response(`${url.pathname}${url.search}`, {
|
|
306
|
+
headers: { Accept: "application/octet-stream" }
|
|
307
|
+
}).then((response) => response.text());
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
authorizedTrigger,
|
|
313
|
+
actionableFeedback,
|
|
314
|
+
parseGitHubProfiles,
|
|
315
|
+
assertGitHubRepository,
|
|
316
|
+
GitHubClient
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=chunk-PVE52UFH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,Q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AAE;AAAA,EAC1C;AAAA,EAEA,sBAAsB,OAAe,MAAc,MAAc,IAAY;AAC5E,QAAI,SAAS,YAAY,SAAS;AACjC,YAAM,IAAI,MAAM,kCAAkC;AACnD,UAAM,UAAU,SAAS,WAAW,mBAAmB;AACvD,WAAO,KAAK;AAAA,MACX,GAAG,KAAK,eAAe,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,EAAE;AAAA,IACrD;AAAA,EACD;AAAA,EAEA,aAAa,OAAe,MAAc;AACzC,WAAO,KAAK,MAAqB,GAAG,KAAK,eAAe,OAAO,IAAI,CAAC,WAAW;AAAA,EAChF;AAAA,EAEA,qBAAqB,OAAyD;AAC7E,UAAM,MAAM,IAAI,IAAI,MAAM,GAAG;AAC7B,QAAI,GAAG,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,QAAQ;AACnD,YAAM,IAAI,MAAM,mEAAmE;AACpF,WAAO,KAAK,SAAS,GAAG,IAAI,QAAQ,GAAG,IAAI,MAAM,IAAI;AAAA,MACpD,SAAS,EAAE,QAAQ,2BAA2B;AAAA,IAC/C,CAAC,EAAE,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,EACtC;AACD;","names":[]}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type RepositoryFeedbackItem as GitHubFeedbackItem, type RepositoryIssue as GitHubIssue, type RepositoryPullRequest as GitHubPullRequest, RepositoryHttpClient } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export type { GitHubFeedbackItem, GitHubIssue, GitHubPullRequest };
|
|
3
|
+
export interface GitHubRepository {
|
|
4
|
+
name: string;
|
|
5
|
+
full_name: string;
|
|
6
|
+
owner: {
|
|
7
|
+
login: string;
|
|
8
|
+
};
|
|
9
|
+
ssh_url: string;
|
|
10
|
+
default_branch: string;
|
|
11
|
+
html_url: string;
|
|
12
|
+
archived: boolean;
|
|
13
|
+
has_issues: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface GitHubGitIdentity {
|
|
16
|
+
provider: "github";
|
|
17
|
+
profile: string;
|
|
18
|
+
login: string;
|
|
19
|
+
name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
}
|
|
22
|
+
export interface GitHubLabelEvent {
|
|
23
|
+
id: number;
|
|
24
|
+
event: string;
|
|
25
|
+
label?: {
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
actor: {
|
|
29
|
+
login: string;
|
|
30
|
+
} | null;
|
|
31
|
+
}
|
|
32
|
+
export interface GitHubProfile {
|
|
33
|
+
apiBaseUrl: string;
|
|
34
|
+
token: string;
|
|
35
|
+
botLogin: string;
|
|
36
|
+
allowedOrganization?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface GitHubCheckSummary {
|
|
39
|
+
headSha: string;
|
|
40
|
+
status: "pending" | "success" | "failure";
|
|
41
|
+
total: number;
|
|
42
|
+
failed: Array<{
|
|
43
|
+
name: string;
|
|
44
|
+
conclusion: string | null;
|
|
45
|
+
url: string | null;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export interface GitHubRelease {
|
|
49
|
+
id: number;
|
|
50
|
+
tag_name: string;
|
|
51
|
+
target_commitish: string;
|
|
52
|
+
draft: boolean;
|
|
53
|
+
prerelease: boolean;
|
|
54
|
+
html_url: string;
|
|
55
|
+
assets: Array<{
|
|
56
|
+
name: string;
|
|
57
|
+
url: string;
|
|
58
|
+
browser_download_url: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export declare function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile>;
|
|
62
|
+
export declare function assertGitHubRepository(profile: GitHubProfile, owner: string, repo: string): void;
|
|
63
|
+
export declare class GitHubClient extends RepositoryHttpClient {
|
|
64
|
+
readonly profile: GitHubProfile;
|
|
65
|
+
constructor(profile: GitHubProfile);
|
|
66
|
+
protected response(path: string, init?: RequestInit): Promise<Response>;
|
|
67
|
+
protected repositoryPath(owner: string, repo: string): string;
|
|
68
|
+
listRepositories(): Promise<GitHubRepository[]>;
|
|
69
|
+
listOpenIssues(owner: string, repo: string): Promise<(GitHubIssue & {
|
|
70
|
+
pull_request?: unknown;
|
|
71
|
+
})[]>;
|
|
72
|
+
listIssueEvents(owner: string, repo: string, number: number): Promise<GitHubLabelEvent[]>;
|
|
73
|
+
isOrganizationMember(login: string): Promise<boolean>;
|
|
74
|
+
authorizedTrigger(owner: string, repo: string, number: number, trigger: string, done: string): Promise<{
|
|
75
|
+
issue: GitHubIssue & {
|
|
76
|
+
pull_request?: unknown;
|
|
77
|
+
};
|
|
78
|
+
actor: string;
|
|
79
|
+
eventId: number;
|
|
80
|
+
} | null>;
|
|
81
|
+
resolveGitIdentity(profile: string): Promise<GitHubGitIdentity>;
|
|
82
|
+
updateIssue(owner: string, repo: string, number: number, patch: Record<string, unknown>): Promise<GitHubIssue>;
|
|
83
|
+
ensureLabel(owner: string, repo: string, name: string): Promise<{
|
|
84
|
+
id: number;
|
|
85
|
+
name: string;
|
|
86
|
+
} | {
|
|
87
|
+
id: number;
|
|
88
|
+
name: string;
|
|
89
|
+
}>;
|
|
90
|
+
addFeedbackReaction(owner: string, repo: string, kind: string, id: number): Promise<unknown>;
|
|
91
|
+
replyFeedback(owner: string, repo: string, pr: number, kind: string, id: number, body: string): Promise<unknown>;
|
|
92
|
+
getCommit(owner: string, repo: string, ref: string): Promise<{
|
|
93
|
+
sha: string;
|
|
94
|
+
}>;
|
|
95
|
+
isAncestor(owner: string, repo: string, ancestor: string, descendant: string): Promise<boolean>;
|
|
96
|
+
listPullRequestFeedback(owner: string, repo: string, number: number, signal?: AbortSignal): Promise<GitHubFeedbackItem[]>;
|
|
97
|
+
getCheckSummary(owner: string, repo: string, headSha: string): Promise<GitHubCheckSummary>;
|
|
98
|
+
/** Human feedback checked against current membership; delivery receipts use raw reads. */
|
|
99
|
+
listActionablePullRequestFeedback(owner: string, repo: string, number: number, signal?: AbortSignal): Promise<GitHubFeedbackItem[]>;
|
|
100
|
+
listFeedbackReplies(owner: string, repo: string, pr: number, kind: string): Promise<Record<string, unknown>[]>;
|
|
101
|
+
listFeedbackReactions(owner: string, repo: string, kind: string, id: number): Promise<{
|
|
102
|
+
id: number;
|
|
103
|
+
content: string;
|
|
104
|
+
user: {
|
|
105
|
+
login: string;
|
|
106
|
+
};
|
|
107
|
+
}[]>;
|
|
108
|
+
listReleases(owner: string, repo: string): Promise<GitHubRelease[]>;
|
|
109
|
+
downloadReleaseAsset(asset: GitHubRelease["assets"][number]): Promise<string>;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=client.d.ts.map
|