@leitwerk-dev/github 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -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 +4 -1
- package/dist/capability.d.ts.map +1 -1
- package/dist/{chunk-PVE52UFH.js → chunk-6X3F3VHK.js} +48 -22
- package/dist/chunk-6X3F3VHK.js.map +1 -0
- package/dist/client.d.ts +98 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/external.d.ts +65 -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 +120 -139
- package/dist/index.js.map +1 -1
- package/dist/issue-watcher.d.ts +12 -0
- package/dist/issue-watcher.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 +45 -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 +29 -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 +4 -1
- package/src/client.ts +135 -30
- package/src/external.ts +53 -0
- package/src/index.ts +31 -11
- package/src/issue-watcher.ts +16 -1
- package/src/testing/tool-fixture.ts +126 -0
- package/src/testing.ts +91 -9
- package/src/tools.ts +158 -175
- package/dist/chunk-PVE52UFH.js.map +0 -1
package/dist/external.d.ts
CHANGED
|
@@ -1,58 +1,108 @@
|
|
|
1
1
|
import { type ExternalEventDescription } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare const GITHUB_PR_STATE_KIND = "@leitwerk-private/github.pr_state";
|
|
4
|
+
/** @public */
|
|
3
5
|
export interface GitHubPullRequestSourceConfig {
|
|
6
|
+
/** @public */
|
|
4
7
|
profile: string;
|
|
8
|
+
/** @public */
|
|
5
9
|
owner: string;
|
|
10
|
+
/** @public */
|
|
6
11
|
repo: string;
|
|
12
|
+
/** @public */
|
|
7
13
|
prNumber: number;
|
|
14
|
+
/** @public */
|
|
8
15
|
headSha: string;
|
|
16
|
+
/** @public */
|
|
9
17
|
feedbackCursor: number;
|
|
18
|
+
/** @public */
|
|
10
19
|
lastConflictKey?: string | null;
|
|
20
|
+
/** @public */
|
|
11
21
|
pollInterval?: string;
|
|
22
|
+
/** @internal */
|
|
12
23
|
disabled?: boolean;
|
|
24
|
+
/** @public */
|
|
13
25
|
eventKinds?: Array<"checks" | "feedback" | "merged" | "closed" | "merge_conflict">;
|
|
26
|
+
/** @internal */
|
|
14
27
|
checkStatuses?: Array<"pending" | "success" | "failure">;
|
|
15
28
|
}
|
|
29
|
+
/** @internal */
|
|
16
30
|
export declare const GITHUB_RELEASE_KIND = "@leitwerk-private/github.release";
|
|
31
|
+
/** @internal */
|
|
17
32
|
export interface GitHubReleaseSourceConfig {
|
|
33
|
+
/** @internal */
|
|
18
34
|
profile: string;
|
|
35
|
+
/** @internal */
|
|
19
36
|
owner: string;
|
|
37
|
+
/** @internal */
|
|
20
38
|
repo: string;
|
|
39
|
+
/** @internal */
|
|
21
40
|
mergeSha: string;
|
|
41
|
+
/** @internal */
|
|
22
42
|
pollInterval?: string;
|
|
43
|
+
/** @internal */
|
|
23
44
|
disabled?: boolean;
|
|
24
45
|
}
|
|
46
|
+
/** @internal */
|
|
25
47
|
export declare function describeGitHubEvent(event: unknown): ExternalEventDescription;
|
|
48
|
+
/** @public */
|
|
26
49
|
export declare const GITHUB_PR_TERMINAL_KIND = "@leitwerk-public/github.pr_terminal";
|
|
50
|
+
/** @public */
|
|
27
51
|
export declare const GITHUB_PR_FEEDBACK_KIND = "@leitwerk-public/github.pr_feedback";
|
|
52
|
+
/** @public */
|
|
28
53
|
export declare const GITHUB_ISSUE_CANCELLED_KIND = "@leitwerk-public/github.issue_cancelled";
|
|
54
|
+
/** @public */
|
|
29
55
|
export interface GitHubPullRequestTerminalSourceConfig {
|
|
56
|
+
/** @public */
|
|
30
57
|
profile: string;
|
|
58
|
+
/** @public */
|
|
31
59
|
owner: string;
|
|
60
|
+
/** @public */
|
|
32
61
|
repo: string;
|
|
62
|
+
/** @public */
|
|
33
63
|
prNumber: number;
|
|
64
|
+
/** @public */
|
|
34
65
|
pollInterval?: string;
|
|
66
|
+
/** @public */
|
|
35
67
|
terminalOutcome?: "merged" | "closed";
|
|
68
|
+
/** @internal */
|
|
36
69
|
disabled?: boolean;
|
|
37
70
|
}
|
|
71
|
+
/** @public */
|
|
38
72
|
export interface GitHubFeedbackSourceConfig extends GitHubPullRequestTerminalSourceConfig {
|
|
73
|
+
/** @public */
|
|
39
74
|
conversationCursor: number;
|
|
75
|
+
/** @public */
|
|
40
76
|
reviewCursor: number;
|
|
77
|
+
/** @public */
|
|
41
78
|
inlineCursor: number;
|
|
79
|
+
/** @public */
|
|
42
80
|
quietPeriodMs: number;
|
|
43
81
|
}
|
|
82
|
+
/** @public */
|
|
44
83
|
export interface GitHubIssueCancelledSourceConfig {
|
|
84
|
+
/** @public */
|
|
45
85
|
profile: string;
|
|
86
|
+
/** @public */
|
|
46
87
|
owner: string;
|
|
88
|
+
/** @public */
|
|
47
89
|
repo: string;
|
|
90
|
+
/** @public */
|
|
48
91
|
issueNumber: number;
|
|
92
|
+
/** @public */
|
|
49
93
|
triggerLabel: string;
|
|
94
|
+
/** @public */
|
|
50
95
|
pollInterval?: string;
|
|
51
96
|
}
|
|
97
|
+
/** @public */
|
|
52
98
|
export declare const GITHUB_CHECKS_KIND = "@leitwerk-public/github.checks";
|
|
99
|
+
/** @public */
|
|
53
100
|
export declare const githubExternal: {
|
|
101
|
+
/** @public */
|
|
54
102
|
checks: <TParams, TState>(resolve: (ctx: {
|
|
103
|
+
/** @public */
|
|
55
104
|
params: TParams;
|
|
105
|
+
/** @public */
|
|
56
106
|
state: TState;
|
|
57
107
|
}) => {
|
|
58
108
|
profile: string;
|
|
@@ -61,24 +111,39 @@ export declare const githubExternal: {
|
|
|
61
111
|
prNumber: number;
|
|
62
112
|
headSha: string;
|
|
63
113
|
}) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
114
|
+
/** @public */
|
|
64
115
|
issueCancelled: <TParams, TState>(resolve: (ctx: {
|
|
116
|
+
/** @public */
|
|
65
117
|
params: TParams;
|
|
118
|
+
/** @public */
|
|
66
119
|
state: TState;
|
|
67
120
|
}) => GitHubIssueCancelledSourceConfig) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
121
|
+
/** @public */
|
|
68
122
|
pullRequestTerminal: <TParams, TState>(resolve: (ctx: {
|
|
123
|
+
/** @public */
|
|
69
124
|
params: TParams;
|
|
125
|
+
/** @public */
|
|
70
126
|
state: TState;
|
|
71
127
|
}) => GitHubPullRequestTerminalSourceConfig) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
128
|
+
/** @public */
|
|
72
129
|
pullRequestFeedback: <TParams, TState>(resolve: (ctx: {
|
|
130
|
+
/** @public */
|
|
73
131
|
params: TParams;
|
|
132
|
+
/** @public */
|
|
74
133
|
state: TState;
|
|
75
134
|
}) => GitHubFeedbackSourceConfig) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
135
|
+
/** @internal */
|
|
76
136
|
releaseContaining: <TParams, TState>(resolve: (ctx: {
|
|
137
|
+
/** @public */
|
|
77
138
|
params: TParams;
|
|
139
|
+
/** @public */
|
|
78
140
|
state: TState;
|
|
79
141
|
}) => GitHubReleaseSourceConfig) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
142
|
+
/** @public */
|
|
80
143
|
pullRequestState: <TParams, TState>(resolve: (ctx: {
|
|
144
|
+
/** @public */
|
|
81
145
|
params: TParams;
|
|
146
|
+
/** @public */
|
|
82
147
|
state: TState;
|
|
83
148
|
}) => GitHubPullRequestSourceConfig) => import("@leitwerk-dev/process-sdk").ExternalActionSource<TParams, TState, unknown, Record<string, unknown>>;
|
|
84
149
|
};
|
package/dist/external.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,oBAAoB,sCAAsC,CAAC;AAExE,MAAM,WAAW,6BAA6B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,CAAC,CAAC;IACnF,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AAEtE,MAAM,WAAW,yBAAyB;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CA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} from "@leitwerk-dev/process-sdk";
|
|
2
2
|
import { type GitHubIntegration } from "./capability.js";
|
|
3
|
-
|
|
4
|
-
readonly id: "github";
|
|
5
|
-
readonly version: "0.1.9";
|
|
6
|
-
};
|
|
3
|
+
/** @public */
|
|
7
4
|
declare const extension: LeitwerkExtensionModule;
|
|
8
|
-
export * from "./capability.js";
|
|
9
|
-
export * from "./client.js";
|
|
10
|
-
export * from "./external.js";
|
|
11
5
|
export default extension;
|
|
12
|
-
/** Register shared tools and polling with an explicit integration. */
|
|
6
|
+
/** Register shared tools and polling with an explicit integration. @public */
|
|
13
7
|
export declare function setupGitHubIntegration(api: Parameters<NonNullable<LeitwerkExtensionModule["setupServer"]>>[0], integration: GitHubIntegration, options?: {
|
|
8
|
+
/** @public */
|
|
14
9
|
now?: () => number;
|
|
15
|
-
}):
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
}): {
|
|
11
|
+
/** @public */
|
|
12
|
+
poll(): Promise<import("@leitwerk-dev/watcher-utils").PollResult>;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export { resolveGitHubProjectBinding } from "./binding.js";
|
|
15
|
+
export type { GitHubIntegration } from "./capability.js";
|
|
16
|
+
export { githubIntegration } from "./capability.js";
|
|
17
|
+
export type { GitHubCheckSummary, GitHubGitIdentity, GitHubIssue, GitHubPullRequest, } from "./client.js";
|
|
18
|
+
export { GITHUB_CHECKS_KIND, GITHUB_ISSUE_CANCELLED_KIND, GITHUB_PR_FEEDBACK_KIND, GITHUB_PR_STATE_KIND, GITHUB_PR_TERMINAL_KIND, githubExternal, } from "./external.js";
|
|
19
|
+
export { githubIssueWatcherSource } from "./issue-watcher.js";
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,iBAAiB,CAAC;AAY5E,cAAc;AACd,QAAA,MAAM,SAAS,EAAE,uBAahB,CAAC;AAEF,eAAe,SAAS,CAAC;AAEzB,8EAA8E;AAC9E,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvE,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IACR,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACd;;;cAON;AAED,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EACX,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
GitHubClient,
|
|
3
3
|
assertGitHubRepository,
|
|
4
4
|
parseGitHubProfiles
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6X3F3VHK.js";
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
import { coreHostCapabilities } from "@leitwerk-dev/process-sdk";
|
|
@@ -46,34 +46,40 @@ var GITHUB_PR_FEEDBACK_KIND = "@leitwerk-public/github.pr_feedback";
|
|
|
46
46
|
var GITHUB_ISSUE_CANCELLED_KIND = "@leitwerk-public/github.issue_cancelled";
|
|
47
47
|
var GITHUB_CHECKS_KIND = "@leitwerk-public/github.checks";
|
|
48
48
|
var githubExternal = {
|
|
49
|
+
/** @public */
|
|
49
50
|
checks: defineExternalActionSource({
|
|
50
51
|
kind: GITHUB_CHECKS_KIND,
|
|
51
52
|
describeEvent: describeGitHubEvent,
|
|
52
53
|
label: "GitHub Actions failures"
|
|
53
54
|
}),
|
|
55
|
+
/** @public */
|
|
54
56
|
issueCancelled: defineExternalActionSource({
|
|
55
57
|
kind: GITHUB_ISSUE_CANCELLED_KIND,
|
|
56
58
|
describeEvent: () => ({ summary: "Source issue cancelled" }),
|
|
57
59
|
label: "GitHub source issue cancelled",
|
|
58
60
|
description: "Fires when the source issue closes or loses its trigger label"
|
|
59
61
|
}),
|
|
62
|
+
/** @public */
|
|
60
63
|
pullRequestTerminal: defineExternalActionSource({
|
|
61
64
|
kind: GITHUB_PR_TERMINAL_KIND,
|
|
62
65
|
describeEvent: describeGitHubEvent,
|
|
63
66
|
label: "GitHub pull request merged or closed",
|
|
64
67
|
description: "Fires when the tracked pull request reaches a terminal state"
|
|
65
68
|
}),
|
|
69
|
+
/** @public */
|
|
66
70
|
pullRequestFeedback: defineExternalActionSource({
|
|
67
71
|
kind: GITHUB_PR_FEEDBACK_KIND,
|
|
68
72
|
describeEvent: () => ({ summary: "Pull request feedback received" }),
|
|
69
73
|
label: "GitHub pull request feedback",
|
|
70
74
|
description: "Fires after unseen human feedback has been quiet long enough to batch"
|
|
71
75
|
}),
|
|
76
|
+
/** @internal */
|
|
72
77
|
releaseContaining: defineExternalActionSource({
|
|
73
78
|
kind: GITHUB_RELEASE_KIND,
|
|
74
79
|
label: "Published GitHub release",
|
|
75
80
|
description: "Fires when a published release contains the tracked merge commit"
|
|
76
81
|
}),
|
|
82
|
+
/** @public */
|
|
77
83
|
pullRequestState: defineExternalActionSource({
|
|
78
84
|
kind: GITHUB_PR_STATE_KIND,
|
|
79
85
|
describeEvent: describeGitHubEvent,
|
|
@@ -500,11 +506,8 @@ function createGitHubProvider(deps, integration, options = {}) {
|
|
|
500
506
|
|
|
501
507
|
// src/tools.ts
|
|
502
508
|
import {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
recordWriteIfMissing
|
|
506
|
-
} from "@leitwerk-dev/external-writes";
|
|
507
|
-
import {
|
|
509
|
+
existingObject,
|
|
510
|
+
matchesPatch,
|
|
508
511
|
numberArg,
|
|
509
512
|
objectArg,
|
|
510
513
|
projectParameters,
|
|
@@ -517,13 +520,7 @@ var resolveGitHubProjectBinding = (ctx) => resolveRepositoryProjectBinding(ctx,
|
|
|
517
520
|
|
|
518
521
|
// src/tools.ts
|
|
519
522
|
var object = (value) => objectArg(value, "Expected an object");
|
|
520
|
-
|
|
521
|
-
const existing = (await comments).find((comment) => String(comment.body).includes(marker));
|
|
522
|
-
return existing ?? post(`${body()}
|
|
523
|
-
|
|
524
|
-
${marker}`);
|
|
525
|
-
}
|
|
526
|
-
function registerGitHubTools(api, integration, writes) {
|
|
523
|
+
function registerGitHubTools(api, integration) {
|
|
527
524
|
const target = (ctx) => {
|
|
528
525
|
const binding = resolveGitHubProjectBinding(ctx);
|
|
529
526
|
assertGitHubRepository(
|
|
@@ -536,11 +533,7 @@ function registerGitHubTools(api, integration, writes) {
|
|
|
536
533
|
api.tool({
|
|
537
534
|
name: "github_resolve_git_identity",
|
|
538
535
|
description: "Resolve the configured GitHub Git identity",
|
|
539
|
-
parameters:
|
|
540
|
-
type: "object",
|
|
541
|
-
properties: { projectKey: { type: "string" } },
|
|
542
|
-
required: ["projectKey"]
|
|
543
|
-
},
|
|
536
|
+
parameters: projectParameters(),
|
|
544
537
|
async execute(ctx) {
|
|
545
538
|
const t = target(ctx);
|
|
546
539
|
return integration.client(t.profile).resolveGitIdentity(t.profile);
|
|
@@ -551,12 +544,22 @@ function registerGitHubTools(api, integration, writes) {
|
|
|
551
544
|
"github_update_issue",
|
|
552
545
|
"github_add_issue_comment",
|
|
553
546
|
"github_add_pull_request_feedback_reaction",
|
|
554
|
-
"github_reply_to_pull_request_feedback"
|
|
547
|
+
"github_reply_to_pull_request_feedback",
|
|
548
|
+
"github_add_pull_request_comment",
|
|
549
|
+
"github_update_pull_request"
|
|
555
550
|
]) {
|
|
551
|
+
const pullRequest = name === "github_add_pull_request_comment" || name === "github_update_pull_request";
|
|
552
|
+
const update = name === "github_update_issue" || name === "github_update_pull_request";
|
|
556
553
|
api.tool({
|
|
557
554
|
name,
|
|
558
|
-
description: "Reconcile GitHub delivery in the current process project",
|
|
559
|
-
parameters:
|
|
555
|
+
description: pullRequest ? update ? "Update a GitHub pull request" : "Comment on a GitHub pull request" : "Reconcile GitHub delivery in the current process project",
|
|
556
|
+
parameters: pullRequest ? projectParameters(
|
|
557
|
+
{
|
|
558
|
+
pullRequestNumber: { type: "integer" },
|
|
559
|
+
...update ? { patch: { type: "object" } } : { body: { type: "string" }, writeKey: { type: "string" } }
|
|
560
|
+
},
|
|
561
|
+
["pullRequestNumber", update ? "patch" : "body"]
|
|
562
|
+
) : {
|
|
560
563
|
type: "object",
|
|
561
564
|
properties: {
|
|
562
565
|
projectKey: { type: "string" },
|
|
@@ -575,64 +578,96 @@ function registerGitHubTools(api, integration, writes) {
|
|
|
575
578
|
const input = object(args);
|
|
576
579
|
const t = target(ctx);
|
|
577
580
|
const client = integration.client(t.profile);
|
|
578
|
-
const key = typeof input.writeKey === "string" ? stringArg(input, "writeKey") : ctx.idempotencyKey;
|
|
581
|
+
const key = !(pullRequest && update) && typeof input.writeKey === "string" ? stringArg(input, "writeKey") : ctx.idempotencyKey;
|
|
582
|
+
const signal = pullRequest ? ctx.signal : void 0;
|
|
579
583
|
const marker = `<!-- leitwerk-write:${ctx.process.id}:${key} -->`;
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const issueNumber = numberArg(
|
|
609
|
-
{ issueNumber: input.issueNumber ?? input.pullRequestNumber },
|
|
610
|
-
"issueNumber"
|
|
611
|
-
);
|
|
612
|
-
value = await reconcileComment(
|
|
613
|
-
name === "github_reply_to_pull_request_feedback" ? client.listFeedbackReplies(
|
|
584
|
+
const issueNumber = () => numberArg(
|
|
585
|
+
input,
|
|
586
|
+
pullRequest || input.issueNumber == null ? "pullRequestNumber" : "issueNumber"
|
|
587
|
+
);
|
|
588
|
+
const findComment = async () => {
|
|
589
|
+
const replies = name === "github_reply_to_pull_request_feedback" ? await client.listFeedbackReplies(
|
|
590
|
+
t.owner,
|
|
591
|
+
t.repo,
|
|
592
|
+
issueNumber(),
|
|
593
|
+
stringArg(input, "feedbackKind")
|
|
594
|
+
) : await client.listIssueComments(t.owner, t.repo, issueNumber(), signal);
|
|
595
|
+
return replies.find(
|
|
596
|
+
(comment) => String(comment.body).includes(marker) && (name !== "github_reply_to_pull_request_feedback" || input.feedbackKind !== "inline" || object(comment).in_reply_to_id === numberArg(input, "feedbackId"))
|
|
597
|
+
) ?? null;
|
|
598
|
+
};
|
|
599
|
+
const result = await ctx.externalWrites.ensure(
|
|
600
|
+
{
|
|
601
|
+
writeType: pullRequest ? update ? "github.update_pr" : "github.comment" : name,
|
|
602
|
+
dedupKey: key
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
reconcile: async (phase) => existingObject(async () => {
|
|
606
|
+
if (name === "github_ensure_label")
|
|
607
|
+
return (await client.listLabels(t.owner, t.repo)).find(
|
|
608
|
+
(label) => label.name === stringArg(input, "name")
|
|
609
|
+
) ?? null;
|
|
610
|
+
if (update) {
|
|
611
|
+
const current = await client[pullRequest ? "getPullRequest" : "getIssue"](
|
|
614
612
|
t.owner,
|
|
615
613
|
t.repo,
|
|
616
|
-
issueNumber,
|
|
617
|
-
|
|
618
|
-
)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
614
|
+
issueNumber(),
|
|
615
|
+
signal
|
|
616
|
+
);
|
|
617
|
+
return current && (phase === "already_recorded" || matchesPatch(current, object(input.patch))) ? current : null;
|
|
618
|
+
}
|
|
619
|
+
if (name === "github_add_pull_request_feedback_reaction")
|
|
620
|
+
return (await client.listFeedbackReactions(
|
|
622
621
|
t.owner,
|
|
623
622
|
t.repo,
|
|
624
|
-
|
|
623
|
+
stringArg(input, "feedbackKind"),
|
|
624
|
+
numberArg(input, "feedbackId")
|
|
625
|
+
)).find(
|
|
626
|
+
(reaction) => reaction.content === "eyes" && reaction.user.login.toLowerCase() === client.profile.botLogin.toLowerCase()
|
|
627
|
+
) ?? null;
|
|
628
|
+
return findComment();
|
|
629
|
+
}),
|
|
630
|
+
execute: async () => {
|
|
631
|
+
if (name === "github_ensure_label")
|
|
632
|
+
return client.createLabel(t.owner, t.repo, stringArg(input, "name"));
|
|
633
|
+
if (update)
|
|
634
|
+
return pullRequest ? object(
|
|
635
|
+
await client.updatePullRequest(
|
|
636
|
+
t.owner,
|
|
637
|
+
t.repo,
|
|
638
|
+
issueNumber(),
|
|
639
|
+
object(input.patch),
|
|
640
|
+
signal
|
|
641
|
+
)
|
|
642
|
+
) : client.updateIssue(t.owner, t.repo, issueNumber(), object(input.patch));
|
|
643
|
+
if (name === "github_add_pull_request_feedback_reaction")
|
|
644
|
+
return object(
|
|
645
|
+
await client.addFeedbackReaction(
|
|
646
|
+
t.owner,
|
|
647
|
+
t.repo,
|
|
648
|
+
stringArg(input, "feedbackKind"),
|
|
649
|
+
numberArg(input, "feedbackId")
|
|
650
|
+
)
|
|
651
|
+
);
|
|
652
|
+
const body = `${stringArg(input, "body")}
|
|
653
|
+
|
|
654
|
+
${marker}`;
|
|
655
|
+
return object(
|
|
656
|
+
await (name === "github_add_issue_comment" || pullRequest ? client.addIssueComment(t.owner, t.repo, issueNumber(), body, signal) : client.replyFeedback(
|
|
657
|
+
t.owner,
|
|
658
|
+
t.repo,
|
|
659
|
+
issueNumber(),
|
|
625
660
|
stringArg(input, "feedbackKind"),
|
|
626
661
|
numberArg(input, "feedbackId"),
|
|
627
662
|
body
|
|
628
|
-
)
|
|
663
|
+
))
|
|
629
664
|
);
|
|
630
|
-
}
|
|
631
|
-
|
|
665
|
+
},
|
|
666
|
+
toMetadata: (value) => pullRequest ? { owner: t.owner, repo: t.repo, pullRequestNumber: issueNumber() } : { value }
|
|
632
667
|
}
|
|
633
668
|
);
|
|
634
669
|
if (name === "github_ensure_label") return { name: stringArg(input, "name") };
|
|
635
|
-
return
|
|
670
|
+
return result;
|
|
636
671
|
}
|
|
637
672
|
});
|
|
638
673
|
}
|
|
@@ -655,31 +690,19 @@ function registerGitHubTools(api, integration, writes) {
|
|
|
655
690
|
const find = async () => (await client.listPullRequests(t.owner, t.repo, "all")).find(
|
|
656
691
|
(candidate) => candidate.head.ref === head && candidate.base.ref === base
|
|
657
692
|
) ?? null;
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return { number: pr.number, url: pr.html_url };
|
|
670
|
-
});
|
|
671
|
-
} catch (error) {
|
|
672
|
-
pr = await find();
|
|
673
|
-
if (!pr) throw error;
|
|
693
|
+
return ctx.externalWrites.ensure(
|
|
694
|
+
{ writeType: "github.ensure_pr", dedupKey: ctx.idempotencyKey },
|
|
695
|
+
{
|
|
696
|
+
reconcile: () => existingObject(find),
|
|
697
|
+
execute: () => client.createPullRequest(t.owner, t.repo, {
|
|
698
|
+
title: stringArg(input, "title"),
|
|
699
|
+
body: stringArg(input, "body"),
|
|
700
|
+
head,
|
|
701
|
+
base
|
|
702
|
+
}),
|
|
703
|
+
toMetadata: (pr) => ({ number: pr.number, url: pr.html_url })
|
|
674
704
|
}
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
if (!pr) throw new Error("GitHub pull request creation could not be reconciled");
|
|
678
|
-
recordWriteIfMissing(writes, ctx.process.id, identity, {
|
|
679
|
-
number: pr.number,
|
|
680
|
-
url: pr.html_url
|
|
681
|
-
});
|
|
682
|
-
return pr;
|
|
705
|
+
);
|
|
683
706
|
}
|
|
684
707
|
});
|
|
685
708
|
for (const [name, description, numberName, method] of [
|
|
@@ -721,50 +744,14 @@ function registerGitHubTools(api, integration, writes) {
|
|
|
721
744
|
return integration.client(t.profile).getCheckSummary(t.owner, t.repo, stringArg(input, "headSha"));
|
|
722
745
|
}
|
|
723
746
|
});
|
|
724
|
-
for (const definition of [
|
|
725
|
-
{ name: "github_add_pull_request_comment", update: false },
|
|
726
|
-
{ name: "github_update_pull_request", update: true }
|
|
727
|
-
]) {
|
|
728
|
-
api.tool({
|
|
729
|
-
name: definition.name,
|
|
730
|
-
description: definition.update ? "Update a GitHub pull request" : "Comment on a GitHub pull request",
|
|
731
|
-
parameters: projectParameters(
|
|
732
|
-
{
|
|
733
|
-
pullRequestNumber: { type: "integer" },
|
|
734
|
-
...definition.update ? { patch: { type: "object" } } : { body: { type: "string" }, writeKey: { type: "string" } }
|
|
735
|
-
},
|
|
736
|
-
["pullRequestNumber", definition.update ? "patch" : "body"]
|
|
737
|
-
),
|
|
738
|
-
async execute(ctx, input) {
|
|
739
|
-
const t = target(ctx);
|
|
740
|
-
const pr = numberArg(input, "pullRequestNumber");
|
|
741
|
-
const key = !definition.update && typeof input.writeKey === "string" ? stringArg(input, "writeKey") : ctx.idempotencyKey;
|
|
742
|
-
return ensureWrite(
|
|
743
|
-
writes,
|
|
744
|
-
ctx.process.id,
|
|
745
|
-
createWriteIdentity(definition.update ? "github.update_pr" : "github.comment", key),
|
|
746
|
-
async () => {
|
|
747
|
-
if (definition.update)
|
|
748
|
-
await integration.client(t.profile).updatePullRequest(t.owner, t.repo, pr, object(input.patch), ctx.signal);
|
|
749
|
-
else {
|
|
750
|
-
const client = integration.client(t.profile);
|
|
751
|
-
await reconcileComment(
|
|
752
|
-
client.listIssueComments(t.owner, t.repo, pr, ctx.signal),
|
|
753
|
-
`<!-- leitwerk-write:${ctx.process.id}:${key} -->`,
|
|
754
|
-
() => stringArg(input, "body"),
|
|
755
|
-
(body) => client.addIssueComment(t.owner, t.repo, pr, body, ctx.signal)
|
|
756
|
-
);
|
|
757
|
-
}
|
|
758
|
-
return { owner: t.owner, repo: t.repo, pullRequestNumber: pr };
|
|
759
|
-
}
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
747
|
}
|
|
765
748
|
|
|
766
749
|
// src/index.ts
|
|
767
|
-
var manifest = {
|
|
750
|
+
var manifest = {
|
|
751
|
+
id: "github",
|
|
752
|
+
/** @internal */
|
|
753
|
+
version: "0.1.9"
|
|
754
|
+
};
|
|
768
755
|
var extension = {
|
|
769
756
|
manifest,
|
|
770
757
|
setupServer(api, config) {
|
|
@@ -784,7 +771,7 @@ function setupGitHubIntegration(api, integration, options = {}) {
|
|
|
784
771
|
api.provide(githubIntegration, integration);
|
|
785
772
|
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
786
773
|
if (!deps || Array.isArray(deps)) return;
|
|
787
|
-
registerGitHubTools(api, integration
|
|
774
|
+
registerGitHubTools(api, integration);
|
|
788
775
|
return createGitHubProvider(deps, integration, options);
|
|
789
776
|
}
|
|
790
777
|
export {
|
|
@@ -793,16 +780,10 @@ export {
|
|
|
793
780
|
GITHUB_PR_FEEDBACK_KIND,
|
|
794
781
|
GITHUB_PR_STATE_KIND,
|
|
795
782
|
GITHUB_PR_TERMINAL_KIND,
|
|
796
|
-
GITHUB_RELEASE_KIND,
|
|
797
|
-
GitHubClient,
|
|
798
|
-
assertGitHubRepository,
|
|
799
783
|
index_default as default,
|
|
800
|
-
describeGitHubEvent,
|
|
801
784
|
githubExternal,
|
|
802
785
|
githubIntegration,
|
|
803
786
|
githubIssueWatcherSource,
|
|
804
|
-
manifest,
|
|
805
|
-
parseGitHubProfiles,
|
|
806
787
|
resolveGitHubProjectBinding,
|
|
807
788
|
setupGitHubIntegration
|
|
808
789
|
};
|