@leitwerk-dev/github-repo-change 0.3.1 → 0.4.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 +7 -3
- package/dist/index.d.ts +38 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -182
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +13 -19
- package/dist/launcher.d.ts.map +1 -1
- package/dist/process.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +21 -9
- package/src/launcher.ts +27 -109
- package/src/process.ts +21 -96
package/README.md
CHANGED
|
@@ -7,8 +7,11 @@ and this extension on the server and worker. The extension is opt-in.
|
|
|
7
7
|
The UI launcher selects a server-owned GitHub profile, a visible repository, and
|
|
8
8
|
a requested change. Launch checks repository visibility and SSH read/write access,
|
|
9
9
|
pins the bot Git identity, and uses the default branch as the base. Replaying a UI
|
|
10
|
-
launch generates a new work branch.
|
|
11
|
-
approval
|
|
10
|
+
launch generates a new work branch. The [shared workflow](../coding/README.md#streamlined-coordinated-changes)
|
|
11
|
+
requires plan approval, then simplifies and publishes automatically. UI launches
|
|
12
|
+
can skip plan approval or simplification; relaunch preserves both choices.
|
|
13
|
+
Issue launches read `leitwerk-skip-simplification` after implementation, never use
|
|
14
|
+
labels to bypass plan approval, and retain completed routing decisions on recovery.
|
|
12
15
|
|
|
13
16
|
## Configuration
|
|
14
17
|
|
|
@@ -42,7 +45,8 @@ be overridden through launcher input; existing instances retain resolved wiring.
|
|
|
42
45
|
|
|
43
46
|
## Delivery and recovery
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
Unchanged work completes without a PR; source issues stay open, lose the trigger,
|
|
49
|
+
and receive a comment. Otherwise the shared lifecycle commits and pushes the work branch, then
|
|
46
50
|
creates or reconciles one PR. It settles human feedback for two minutes, acknowledges
|
|
47
51
|
it, and starts a fresh repair turn. Replies and other provider writes reconcile
|
|
48
52
|
across retries. GitHub checks trigger repair only for the tracked request revision;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type GitHubGitIdentity } from "@leitwerk-dev/github";
|
|
2
|
+
import type { LaunchPreparationCheck, LeitwerkExtensionModule, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
import { type LauncherDependencies } from "./launcher.js";
|
|
4
|
+
import type { GitHubRepoChangeParams } from "./params.js";
|
|
2
5
|
/** @public */
|
|
3
6
|
export declare const manifest: {
|
|
4
7
|
/** @public */
|
|
@@ -18,19 +21,19 @@ export declare function createGitHubRepoChange(options: {
|
|
|
18
21
|
/** @public */
|
|
19
22
|
extension: LeitwerkExtensionModule;
|
|
20
23
|
/** @public */
|
|
21
|
-
process: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<
|
|
24
|
+
process: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<GitHubRepoChangeParams, import("@leitwerk-dev/coding/repository-change-state").RepositoryChangeState>;
|
|
22
25
|
/** @public */
|
|
23
26
|
launcher: {
|
|
24
|
-
/** @
|
|
25
|
-
configure
|
|
26
|
-
/** @
|
|
27
|
-
preparationChecks: (_input: unknown, { params }:
|
|
28
|
-
/** @
|
|
27
|
+
/** @internal */
|
|
28
|
+
configure(value: LauncherDependencies | null): void;
|
|
29
|
+
/** @internal */
|
|
30
|
+
preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) => LaunchPreparationCheck<GitHubRepoChangeParams>[];
|
|
31
|
+
/** @internal */
|
|
29
32
|
resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
|
|
30
|
-
/** @
|
|
31
|
-
resolveGitIdentity: (profile: string) => Promise<
|
|
32
|
-
/** @
|
|
33
|
-
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<
|
|
33
|
+
/** @internal */
|
|
34
|
+
resolveGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
|
|
35
|
+
/** @internal */
|
|
36
|
+
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
|
|
34
37
|
/** @internal */
|
|
35
38
|
resolveIssueLaunchConfig(event: {
|
|
36
39
|
/** @internal */
|
|
@@ -41,8 +44,10 @@ export declare function createGitHubRepoChange(options: {
|
|
|
41
44
|
issue: Pick<import("@leitwerk-dev/github").GitHubIssue, "number" | "title" | "body" | "html_url">;
|
|
42
45
|
/** @internal */
|
|
43
46
|
labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
|
|
44
|
-
}): Promise<
|
|
47
|
+
}): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
|
|
45
48
|
};
|
|
49
|
+
/** @internal */
|
|
50
|
+
workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<GitHubRepoChangeParams>;
|
|
46
51
|
};
|
|
47
52
|
};
|
|
48
53
|
export * from "./launcher.js";
|
|
@@ -50,17 +55,17 @@ export * from "./params.js";
|
|
|
50
55
|
export * from "./process.js";
|
|
51
56
|
export * from "./profile-bindings.js";
|
|
52
57
|
/** @public */
|
|
53
|
-
export declare const defaultExtension: LeitwerkExtensionModule, githubRepoChangeProcess: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<
|
|
54
|
-
/** @
|
|
55
|
-
configure
|
|
56
|
-
/** @
|
|
57
|
-
preparationChecks: (_input: unknown, { params }:
|
|
58
|
-
/** @
|
|
58
|
+
export declare const defaultExtension: LeitwerkExtensionModule, githubRepoChangeProcess: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<GitHubRepoChangeParams, import("@leitwerk-dev/coding/repository-change-state").RepositoryChangeState>, defaultGitHubRepoChangeLauncher: {
|
|
59
|
+
/** @internal */
|
|
60
|
+
configure(value: LauncherDependencies | null): void;
|
|
61
|
+
/** @internal */
|
|
62
|
+
preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) => LaunchPreparationCheck<GitHubRepoChangeParams>[];
|
|
63
|
+
/** @internal */
|
|
59
64
|
resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
|
|
60
|
-
/** @
|
|
61
|
-
resolveGitIdentity: (profile: string) => Promise<
|
|
62
|
-
/** @
|
|
63
|
-
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<
|
|
65
|
+
/** @internal */
|
|
66
|
+
resolveGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
|
|
67
|
+
/** @internal */
|
|
68
|
+
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
|
|
64
69
|
/** @internal */
|
|
65
70
|
resolveIssueLaunchConfig(event: {
|
|
66
71
|
/** @internal */
|
|
@@ -71,11 +76,19 @@ export declare const defaultExtension: LeitwerkExtensionModule, githubRepoChange
|
|
|
71
76
|
issue: Pick<import("@leitwerk-dev/github").GitHubIssue, "number" | "title" | "body" | "html_url">;
|
|
72
77
|
/** @internal */
|
|
73
78
|
labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
|
|
74
|
-
}): Promise<
|
|
79
|
+
}): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
|
|
75
80
|
};
|
|
81
|
+
/** @internal */
|
|
82
|
+
workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<GitHubRepoChangeParams>;
|
|
76
83
|
};
|
|
77
84
|
/** @public */
|
|
78
|
-
export declare const configureGitHubRepoChangeLauncher: (value:
|
|
85
|
+
export declare const configureGitHubRepoChangeLauncher: (value: LauncherDependencies | null) => void;
|
|
86
|
+
/** @public */
|
|
87
|
+
export declare const githubRepositoryPreparationChecks: (input: unknown, launch: ProcessLaunchConfig<GitHubRepoChangeParams>) => readonly LaunchPreparationCheck<GitHubRepoChangeParams>[];
|
|
88
|
+
/** @public */
|
|
89
|
+
export declare const resolveGitHubGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
|
|
90
|
+
/** @public */
|
|
91
|
+
export declare const githubRepoChangeUiLauncher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
|
|
79
92
|
/** @internal */
|
|
80
93
|
resolveIssueLaunchConfig(event: {
|
|
81
94
|
/** @internal */
|
|
@@ -86,7 +99,7 @@ export declare const configureGitHubRepoChangeLauncher: (value: import("./launch
|
|
|
86
99
|
issue: Pick<import("@leitwerk-dev/github").GitHubIssue, "number" | "title" | "body" | "html_url">;
|
|
87
100
|
/** @internal */
|
|
88
101
|
labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
|
|
89
|
-
}): Promise<
|
|
102
|
+
}): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
|
|
90
103
|
};
|
|
91
104
|
export default defaultExtension;
|
|
92
105
|
//# 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":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAkC,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,cAAc;AACd,eAAO,MAAM,QAAQ;IACpB,cAAc;;IAEd,cAAc;;IAEd,cAAc;;CAEL,CAAC;AAEX,0FAA0F;AAC1F,cAAc;AACd,cAAc;AACd,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC/C,cAAc;IACd,MAAM,EAAE,OAAO,CAAC;CAChB;IAyBC,cAAc;;IAEd,cAAc;;IAEd,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGf;AAED,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc;AACd,eAAO,MACK,gBAAgB,2BAClB,uBAAuB,wKACtB,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;CACE,CAAC;AAC7C,cAAc;AACd,eAAO,MAAM,iCAAiC,EAAE,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,KAAK,IAC9C,CAAC;AAC3C,cAAc;AACd,eAAO,MAAM,iCAAiC,EAAE,CAC/C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,mBAAmB,CAAC,sBAAsB,CAAC,KAC/C,SAAS,sBAAsB,CAAC,sBAAsB,CAAC,EACV,CAAC;AACnD,cAAc;AACd,eAAO,MAAM,wBAAwB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAClC,CAAC;AACpD,cAAc;AACd,eAAO,MAAM,0BAA0B;;;;;;;;;;;;CAA2C,CAAC;AACnF,eAAe,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { githubIntegration } from "@leitwerk-dev/github";
|
|
|
4
4
|
|
|
5
5
|
// src/launcher.ts
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
createRepositoryChangeLauncher,
|
|
8
|
+
repositoryIssueChangeLaunchConfig
|
|
9
9
|
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
10
10
|
import { createGitSshPreparationCheck } from "@leitwerk-dev/git-ssh";
|
|
11
11
|
|
|
@@ -58,139 +58,65 @@ function githubRepoChangeParams(repository, input) {
|
|
|
58
58
|
doneLabel: null
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
function githubRepoChangeLaunchConfig(params, title, gitIdentity) {
|
|
61
|
+
function githubRepoChangeLaunchConfig(params, title, gitIdentity, repository) {
|
|
62
62
|
const { owner, repo, githubProfile: profile } = params;
|
|
63
63
|
const issue = isIssueOrigin(params);
|
|
64
|
-
return
|
|
65
|
-
|
|
64
|
+
return repositoryIssueChangeLaunchConfig(
|
|
65
|
+
"github",
|
|
66
66
|
params,
|
|
67
67
|
title,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
key: "repo",
|
|
76
|
-
repoLocator: params.repoLocator,
|
|
77
|
-
baseBranch: params.baseBranch,
|
|
78
|
-
workBranch: params.workBranch,
|
|
79
|
-
...issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {},
|
|
80
|
-
metadata: {
|
|
81
|
-
github: { owner, repo, profile, ...issue ? { issueNumber: params.issueNumber } : {} },
|
|
82
|
-
"leitwerk.gitIdentity": gitIdentity
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
};
|
|
68
|
+
`${owner}/${repo}`,
|
|
69
|
+
{
|
|
70
|
+
github: { owner, repo, profile, ...issue ? { issueNumber: params.issueNumber } : {} },
|
|
71
|
+
"leitwerk.gitIdentity": gitIdentity
|
|
72
|
+
},
|
|
73
|
+
repository
|
|
74
|
+
);
|
|
87
75
|
}
|
|
88
76
|
function createGitHubRepoChangeLauncher() {
|
|
89
|
-
|
|
90
|
-
function configureGitHubRepoChangeLauncher2(value) {
|
|
91
|
-
dependencies = value;
|
|
92
|
-
}
|
|
93
|
-
function requireDependencies() {
|
|
94
|
-
if (!dependencies) throw new Error("GitHub repository launcher is not configured");
|
|
95
|
-
return dependencies;
|
|
96
|
-
}
|
|
97
|
-
function githubRepositoryPreparationChecks2(_input, { params }) {
|
|
98
|
-
return [
|
|
99
|
-
repositoryVisibilityCheck(
|
|
100
|
-
"GitHub",
|
|
101
|
-
async () => (await repositories(params.githubProfile)).some(
|
|
102
|
-
(candidate) => candidate.full_name === `${params.owner}/${params.repo}`
|
|
103
|
-
)
|
|
104
|
-
),
|
|
105
|
-
createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
|
|
106
|
-
createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh)
|
|
107
|
-
];
|
|
108
|
-
}
|
|
109
|
-
function resolveProfiles(profile) {
|
|
110
|
-
const { github, gitSsh, profileBindings = {} } = requireDependencies();
|
|
111
|
-
if (!(github.profiles?.() ?? []).includes(profile))
|
|
112
|
-
throw new Error("GitHub profile is not available");
|
|
113
|
-
const binding = resolveProfileBinding(profileBindings, profile);
|
|
114
|
-
if (!gitSsh.profiles().includes(binding.sshCredentialRef))
|
|
115
|
-
throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
|
|
116
|
-
return binding;
|
|
117
|
-
}
|
|
118
|
-
async function resolveGitHubGitIdentity2(profile) {
|
|
119
|
-
if (!profile) throw new Error("A GitHub profile is required to resolve Git identity");
|
|
120
|
-
return requireDependencies().github.client(profile).resolveGitIdentity(profile);
|
|
121
|
-
}
|
|
122
|
-
async function repositories(profile) {
|
|
123
|
-
if (!profile) return [];
|
|
124
|
-
const { github } = requireDependencies();
|
|
125
|
-
if (!(github.profiles?.() ?? []).includes(profile)) return [];
|
|
126
|
-
return github.client(profile).listRepositories();
|
|
127
|
-
}
|
|
128
|
-
const githubRepoChangeUiLauncher2 = createRepositoryChangeUiLauncher({
|
|
77
|
+
return createRepositoryChangeLauncher({
|
|
129
78
|
id: githubRepoChangeUiLauncherId,
|
|
130
79
|
provider: "GitHub",
|
|
131
80
|
providerId: "github",
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
repositories,
|
|
135
|
-
resolveProfiles,
|
|
136
|
-
resolveGitIdentity: resolveGitHubGitIdentity2,
|
|
81
|
+
integration: (deps) => deps.github,
|
|
82
|
+
profile: (params) => params.githubProfile,
|
|
137
83
|
params: githubRepoChangeParams,
|
|
138
84
|
launchConfig: githubRepoChangeLaunchConfig,
|
|
139
|
-
|
|
85
|
+
resolveProfiles(profile, { gitSsh, profileBindings = {} }) {
|
|
86
|
+
const binding = resolveProfileBinding(profileBindings, profile);
|
|
87
|
+
if (!gitSsh.profiles().includes(binding.sshCredentialRef))
|
|
88
|
+
throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
|
|
89
|
+
return binding;
|
|
90
|
+
},
|
|
91
|
+
preparationChecks: (params, dependencies) => [
|
|
92
|
+
createGitSshPreparationCheck("write", params, () => dependencies().gitSsh)
|
|
93
|
+
]
|
|
140
94
|
});
|
|
141
|
-
return {
|
|
142
|
-
/** @public */
|
|
143
|
-
configure: configureGitHubRepoChangeLauncher2,
|
|
144
|
-
/** @public */
|
|
145
|
-
preparationChecks: githubRepositoryPreparationChecks2,
|
|
146
|
-
/** @public */
|
|
147
|
-
resolveProfiles,
|
|
148
|
-
/** @public */
|
|
149
|
-
resolveGitIdentity: resolveGitHubGitIdentity2,
|
|
150
|
-
/** @public */
|
|
151
|
-
launcher: githubRepoChangeUiLauncher2
|
|
152
|
-
};
|
|
153
95
|
}
|
|
154
96
|
|
|
155
97
|
// src/process.ts
|
|
156
|
-
import { createRepositoryChangeProcess } from "@leitwerk-dev/coding";
|
|
157
98
|
import {
|
|
158
|
-
|
|
99
|
+
createPullRequestChangeProcess,
|
|
159
100
|
publicationObject as object,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
readPublicationState,
|
|
163
|
-
reconcilePullRequestSourceIssue,
|
|
164
|
-
resolvePullRequestGitIdentity
|
|
101
|
+
pullRequestPublicationDefaults,
|
|
102
|
+
readPublicationState
|
|
165
103
|
} from "@leitwerk-dev/coding/repository-change-publication";
|
|
166
104
|
import { githubExternal, githubIssueWatcherSource } from "@leitwerk-dev/github";
|
|
167
|
-
var processId = "github_repo_change_process";
|
|
168
|
-
var ids = {
|
|
169
|
-
deliver: "deliver_change",
|
|
170
|
-
feedback: "revise_from_pull_request_feedback",
|
|
171
|
-
ciRepair: "repair_github_checks",
|
|
172
|
-
operator: "ci_operator_action"
|
|
173
|
-
};
|
|
174
105
|
var remote = (state) => readPublicationState(state, "githubRepoChange");
|
|
175
|
-
var deliveryTools = [
|
|
176
|
-
"github_get_pull_request",
|
|
177
|
-
"github_add_pull_request_comment",
|
|
178
|
-
"github_resolve_git_identity",
|
|
179
|
-
"github_ensure_pull_request",
|
|
180
|
-
"github_add_issue_comment",
|
|
181
|
-
"github_add_pull_request_feedback_reaction",
|
|
182
|
-
"github_reply_to_pull_request_feedback",
|
|
183
|
-
"github_get_issue",
|
|
184
|
-
"github_ensure_label",
|
|
185
|
-
"github_update_issue"
|
|
186
|
-
];
|
|
187
106
|
function createGitHubRepoChangeProcess(launcher, docker) {
|
|
188
|
-
const sharedSources =
|
|
107
|
+
const sharedSources = pullRequestPublicationDefaults(
|
|
189
108
|
"github",
|
|
190
109
|
"GitHub",
|
|
191
110
|
githubExternal,
|
|
192
111
|
(params) => params.githubProfile,
|
|
193
|
-
(params) => isIssueOrigin(params) ? params : void 0
|
|
112
|
+
(params) => isIssueOrigin(params) ? params : void 0,
|
|
113
|
+
"name",
|
|
114
|
+
{
|
|
115
|
+
id: "repair_github_checks",
|
|
116
|
+
label: "GitHub checks",
|
|
117
|
+
tools: ["github_get_ci_diagnostics"],
|
|
118
|
+
prompt: (current) => `Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`
|
|
119
|
+
}
|
|
194
120
|
);
|
|
195
121
|
const { requirePr } = sharedSources;
|
|
196
122
|
const failedPipeline = githubExternal.checks(
|
|
@@ -204,11 +130,8 @@ function createGitHubRepoChangeProcess(launcher, docker) {
|
|
|
204
130
|
})
|
|
205
131
|
);
|
|
206
132
|
const sources = [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
kind: "conflict",
|
|
210
|
-
label: "Rebase conflicting pull request",
|
|
211
|
-
source: githubExternal.pullRequestState(({ params, state }) => ({
|
|
133
|
+
sharedSources.conflict(
|
|
134
|
+
githubExternal.pullRequestState(({ params, state }) => ({
|
|
212
135
|
profile: params.githubProfile,
|
|
213
136
|
owner: params.owner,
|
|
214
137
|
repo: params.repo,
|
|
@@ -218,12 +141,8 @@ function createGitHubRepoChangeProcess(launcher, docker) {
|
|
|
218
141
|
feedbackCursor: 0,
|
|
219
142
|
eventKinds: ["merge_conflict"],
|
|
220
143
|
pollInterval: "30s"
|
|
221
|
-
}))
|
|
222
|
-
|
|
223
|
-
kind: "conflict",
|
|
224
|
-
conflict: object(event).conflict
|
|
225
|
-
})
|
|
226
|
-
},
|
|
144
|
+
}))
|
|
145
|
+
),
|
|
227
146
|
sharedSources.feedback,
|
|
228
147
|
{
|
|
229
148
|
id: "github_failure_repair",
|
|
@@ -250,64 +169,17 @@ function createGitHubRepoChangeProcess(launcher, docker) {
|
|
|
250
169
|
...sharedSources.terminal,
|
|
251
170
|
sharedSources.cancelled
|
|
252
171
|
];
|
|
253
|
-
|
|
254
|
-
namespace: "githubRepoChange",
|
|
255
|
-
label: "GitHub PR",
|
|
256
|
-
ids,
|
|
257
|
-
sources,
|
|
258
|
-
tools: {
|
|
259
|
-
delivery: deliveryTools,
|
|
260
|
-
feedback: ["github_get_pull_request", "github_list_pull_request_feedback"],
|
|
261
|
-
ci: ["github_get_ci_diagnostics"]
|
|
262
|
-
},
|
|
263
|
-
identity: (ctx) => resolvePullRequestGitIdentity(ctx, "github", ctx.params.githubProfile),
|
|
264
|
-
reconcileTerminal: reconcilePullRequestSourceIssue(
|
|
265
|
-
"github",
|
|
266
|
-
"name",
|
|
267
|
-
(params) => isIssueOrigin(params) ? params : void 0
|
|
268
|
-
),
|
|
269
|
-
...pullRequestPublicationCallbacks(
|
|
270
|
-
"github",
|
|
271
|
-
"GitHub",
|
|
272
|
-
(params) => isIssueOrigin(params) ? params : void 0
|
|
273
|
-
),
|
|
274
|
-
commitMessage: (kind) => kind === "feedback" ? "fix: address GitHub review feedback" : "fix: repair GitHub checks",
|
|
275
|
-
prompt(kind, current) {
|
|
276
|
-
return kind === "feedback" ? `Address the unseen GitHub pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use GitHub tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.` : `Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
const publication = publicationConfig.fragment;
|
|
280
|
-
publication.watcher({
|
|
281
|
-
id: "use_leitwerk",
|
|
282
|
-
label: "GitHub use-leitwerk issues",
|
|
283
|
-
description: "Launch a remote repository change for GitHub issues carrying the trigger label",
|
|
284
|
-
source: githubIssueWatcherSource,
|
|
285
|
-
preparationChecks: launcher.preparationChecks,
|
|
286
|
-
resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig
|
|
287
|
-
});
|
|
288
|
-
const definition = createRepositoryChangeProcess({
|
|
289
|
-
processId,
|
|
290
|
-
displayName: "GitHub Repo Change",
|
|
172
|
+
return createPullRequestChangeProcess("github", "GitHub", docker, {
|
|
291
173
|
paramsCodec: githubRepoChangeParamsCodec,
|
|
292
174
|
launcher: launcher.launcher,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
repositoryCredentials: ({ params }) => [
|
|
301
|
-
{
|
|
302
|
-
projectKey: "repo",
|
|
303
|
-
kind: "git_ssh",
|
|
304
|
-
credentialRef: params.sshCredentialRef
|
|
305
|
-
}
|
|
306
|
-
],
|
|
307
|
-
publication: publicationConfig
|
|
175
|
+
workflow: launcher.workflow,
|
|
176
|
+
publication: { ...sharedSources.adapter, sources },
|
|
177
|
+
watcher: {
|
|
178
|
+
source: githubIssueWatcherSource,
|
|
179
|
+
preparationChecks: launcher.preparationChecks,
|
|
180
|
+
resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig
|
|
181
|
+
}
|
|
308
182
|
});
|
|
309
|
-
definition.process.runtime = { ...definition.process.runtime, docker };
|
|
310
|
-
return definition.process;
|
|
311
183
|
}
|
|
312
184
|
|
|
313
185
|
// src/index.ts
|
|
@@ -355,12 +227,10 @@ var {
|
|
|
355
227
|
process: githubRepoChangeProcess,
|
|
356
228
|
launcher: defaultGitHubRepoChangeLauncher
|
|
357
229
|
} = createGitHubRepoChange({ docker: true });
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
launcher: githubRepoChangeUiLauncher
|
|
363
|
-
} = defaultGitHubRepoChangeLauncher;
|
|
230
|
+
var configureGitHubRepoChangeLauncher = defaultGitHubRepoChangeLauncher.configure;
|
|
231
|
+
var githubRepositoryPreparationChecks = defaultGitHubRepoChangeLauncher.preparationChecks;
|
|
232
|
+
var resolveGitHubGitIdentity = defaultGitHubRepoChangeLauncher.resolveGitIdentity;
|
|
233
|
+
var githubRepoChangeUiLauncher = defaultGitHubRepoChangeLauncher.launcher;
|
|
364
234
|
var index_default = defaultExtension;
|
|
365
235
|
export {
|
|
366
236
|
configureGitHubRepoChangeLauncher,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/launcher.ts","../src/params.ts","../src/profile-bindings.ts","../src/process.ts"],"sourcesContent":["import { gitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport { githubIntegration } from \"@leitwerk-dev/github\";\nimport type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { createGitHubRepoChangeLauncher } from \"./launcher.js\";\nimport { createGitHubRepoChangeProcess } from \"./process.js\";\nimport { parseProfileBindings } from \"./profile-bindings.js\";\n\n/** @public */\nexport const manifest = {\n\t/** @public */\n\tid: \"github-repo-change\",\n\t/** @public */\n\tversion: \"0.1.9\",\n\t/** @public */\n\trequires: [\"github\", \"coding\", \"git-ssh\"],\n} as const;\n\n/** Load exactly one variant per catalog. Only trusted composition code selects Docker. */\n/** @public */\n/** @public */\nexport function createGitHubRepoChange(options: {\n\t/** @public */\n\tdocker: boolean;\n}) {\n\tif (typeof options.docker !== \"boolean\") throw new Error(\"docker must be a boolean\");\n\tconst launcher = createGitHubRepoChangeLauncher();\n\tconst process = createGitHubRepoChangeProcess(launcher, options.docker);\n\tconst extension: LeitwerkExtensionModule = {\n\t\tmanifest,\n\t\tsetupCatalog(api) {\n\t\t\tapi.registerProcess(process);\n\t\t},\n\t\tsetupServer(api, config) {\n\t\t\tconst github = api.require(githubIntegration);\n\t\t\tconst gitSsh = api.require(gitSshIntegration);\n\t\t\tif (Array.isArray(github) || Array.isArray(gitSsh))\n\t\t\t\tthrow new Error(\"Repository delivery integrations must be singular\");\n\t\t\tlauncher.configure({\n\t\t\t\tgithub,\n\t\t\t\tgitSsh,\n\t\t\t\tprofileBindings: parseProfileBindings(config),\n\t\t\t});\n\t\t\tapi.onStop(() => launcher.configure(null));\n\t\t},\n\t};\n\t/** @public */\n\t/** @public */\n\treturn {\n\t\t/** @public */\n\t\textension,\n\t\t/** @public */\n\t\tprocess,\n\t\t/** @public */\n\t\tlauncher,\n\t};\n}\n\nexport * from \"./launcher.js\";\nexport * from \"./params.js\";\nexport * from \"./process.js\";\nexport * from \"./profile-bindings.js\";\n/** @public */\nexport const {\n\textension: defaultExtension,\n\tprocess: githubRepoChangeProcess,\n\tlauncher: defaultGitHubRepoChangeLauncher,\n} = createGitHubRepoChange({ docker: true });\n/** @public */\nexport const {\n\tconfigure: configureGitHubRepoChangeLauncher,\n\tpreparationChecks: githubRepositoryPreparationChecks,\n\tresolveGitIdentity: resolveGitHubGitIdentity,\n\tlauncher: githubRepoChangeUiLauncher,\n} = defaultGitHubRepoChangeLauncher;\nexport default defaultExtension;\n","import {\n\tcreateRepositoryChangeUiLauncher,\n\trepositoryVisibilityCheck,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\nimport { createGitSshPreparationCheck, type GitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from \"@leitwerk-dev/github\";\nimport type { LaunchPreparationCheck, ProcessLaunchConfig } from \"@leitwerk-dev/process-sdk\";\nimport { type GitHubRepoChangeParams, isIssueOrigin } from \"./params.js\";\nimport { type ProfileBindings, resolveProfileBinding } from \"./profile-bindings.js\";\n\n/** @public */\nexport const githubRepoChangeUiLauncherId = \"github_repo_change_process.ui_launcher\" as const;\n\n/** @public */\nexport function githubRepoChangeParams(\n\trepository: GitHubRepository,\n\tinput: {\n\t\t/** @public */\n\t\tprofile: string;\n\t\t/** @public */\n\t\tsshCredentialRef: string;\n\t\t/** @public */\n\t\tprompt: string;\n\t\t/** @public */\n\t\tworkBranch: string;\n\t},\n): GitHubRepoChangeParams {\n\treturn {\n\t\trepoLocator: repository.ssh_url,\n\t\tbaseBranch: repository.default_branch,\n\t\tworkBranch: input.workBranch,\n\t\tprompt: input.prompt,\n\t\tgithubProfile: input.profile,\n\t\tsshCredentialRef: input.sshCredentialRef,\n\t\towner: repository.owner.login,\n\t\trepo: repository.name,\n\t\torigin: \"ui\",\n\t\tissueNumber: null,\n\t\tissueUrl: null,\n\t\ttriggerLabel: null,\n\t\tdoneLabel: null,\n\t};\n}\n\n/** @public */\nexport function githubRepoChangeLaunchConfig(\n\tparams: GitHubRepoChangeParams,\n\ttitle: string,\n\tgitIdentity: GitHubGitIdentity,\n): ProcessLaunchConfig<GitHubRepoChangeParams> {\n\tconst { owner, repo, githubProfile: profile } = params;\n\tconst issue = isIssueOrigin(params);\n\treturn {\n\t\tprocessId: \"github_repo_change_process\",\n\t\tparams,\n\t\ttitle,\n\t\tstartTurnId: \"generate_plan\",\n\t\t...(issue\n\t\t\t? {\n\t\t\t\t\texternalId: `github:${owner}/${repo}#${params.issueNumber}`,\n\t\t\t\t\texternalUrl: params.issueUrl,\n\t\t\t\t}\n\t\t\t: {}),\n\t\tprojects: [\n\t\t\t{\n\t\t\t\tkey: \"repo\",\n\t\t\t\trepoLocator: params.repoLocator,\n\t\t\t\tbaseBranch: params.baseBranch,\n\t\t\t\tworkBranch: params.workBranch,\n\t\t\t\t...(issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {}),\n\t\t\t\tmetadata: {\n\t\t\t\t\tgithub: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },\n\t\t\t\t\t\"leitwerk.gitIdentity\": gitIdentity,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n}\n\n/** @public */\nexport interface LauncherDependencies {\n\t/** @public */\n\tgithub: GitHubIntegration;\n\t/** @public */\n\tgitSsh: GitSshIntegration;\n\t/** @public */\n\tprofileBindings?: ProfileBindings;\n}\n\n/** @public */\nexport function createGitHubRepoChangeLauncher() {\n\tlet dependencies: LauncherDependencies | null = null;\n\n\t/** @public */\n\tfunction configureGitHubRepoChangeLauncher(value: LauncherDependencies | null): void {\n\t\tdependencies = value;\n\t}\n\n\tfunction requireDependencies(): LauncherDependencies {\n\t\tif (!dependencies) throw new Error(\"GitHub repository launcher is not configured\");\n\t\treturn dependencies;\n\t}\n\n\t/** @public */\n\tfunction githubRepositoryPreparationChecks(\n\t\t_input: unknown,\n\t\t{ params }: ProcessLaunchConfig<GitHubRepoChangeParams>,\n\t): readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] {\n\t\treturn [\n\t\t\trepositoryVisibilityCheck(\"GitHub\", async () =>\n\t\t\t\t(await repositories(params.githubProfile)).some(\n\t\t\t\t\t(candidate) => candidate.full_name === `${params.owner}/${params.repo}`,\n\t\t\t\t),\n\t\t\t),\n\t\t\tcreateGitSshPreparationCheck(\"read\", params, () => requireDependencies().gitSsh),\n\t\t\tcreateGitSshPreparationCheck(\"write\", params, () => requireDependencies().gitSsh),\n\t\t];\n\t}\n\n\t/** @public */\n\tfunction resolveProfiles(profile: string) {\n\t\tconst { github, gitSsh, profileBindings = {} } = requireDependencies();\n\t\tif (!(github.profiles?.() ?? []).includes(profile))\n\t\t\tthrow new Error(\"GitHub profile is not available\");\n\t\tconst binding = resolveProfileBinding(profileBindings, profile);\n\n\t\tif (!gitSsh.profiles().includes(binding.sshCredentialRef))\n\t\t\tthrow new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);\n\t\treturn binding;\n\t}\n\n\t/** @public */\n\tasync function resolveGitHubGitIdentity(profile: string): Promise<GitHubGitIdentity> {\n\t\tif (!profile) throw new Error(\"A GitHub profile is required to resolve Git identity\");\n\t\treturn requireDependencies().github.client(profile).resolveGitIdentity(profile);\n\t}\n\n\tasync function repositories(profile: string): Promise<readonly GitHubRepository[]> {\n\t\tif (!profile) return [];\n\t\tconst { github } = requireDependencies();\n\t\tif (!(github.profiles?.() ?? []).includes(profile)) return [];\n\t\treturn github.client(profile).listRepositories();\n\t}\n\n\tconst githubRepoChangeUiLauncher = createRepositoryChangeUiLauncher({\n\t\tid: githubRepoChangeUiLauncherId,\n\t\tprovider: \"GitHub\",\n\t\tproviderId: \"github\",\n\t\tassertConfigured: requireDependencies,\n\t\tprofiles: () => requireDependencies().github.profiles?.() ?? [],\n\t\trepositories,\n\t\tresolveProfiles,\n\t\tresolveGitIdentity: resolveGitHubGitIdentity,\n\t\tparams: githubRepoChangeParams,\n\t\tlaunchConfig: githubRepoChangeLaunchConfig,\n\t\tpreparationChecks: githubRepositoryPreparationChecks,\n\t});\n\n\treturn {\n\t\t/** @public */\n\t\tconfigure: configureGitHubRepoChangeLauncher,\n\t\t/** @public */\n\t\tpreparationChecks: githubRepositoryPreparationChecks,\n\t\t/** @public */\n\t\tresolveProfiles,\n\t\t/** @public */\n\t\tresolveGitIdentity: resolveGitHubGitIdentity,\n\t\t/** @public */\n\t\tlauncher: githubRepoChangeUiLauncher,\n\t};\n}\n","import {\n\tcreateRepositoryChangeParamsCodec,\n\tnormalizeRepositoryIssueChangeParams,\n\ttype RepositoryChangeLaunchParams,\n\ttype RepositoryIssueOriginParams,\n\ttype RepositoryUiOriginParams,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\n\n/** @public */\ninterface GitHubRepoChangeCommonParams {\n\t/** @public */\n\tgithubProfile: string;\n\t/** @public */\n\tsshCredentialRef: string;\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n}\n\n/** @public */\nexport interface GitHubIssueOriginParams extends RepositoryIssueOriginParams {}\n\n/** @public */\nexport interface GitHubUiOriginParams extends RepositoryUiOriginParams {}\n\n/** @public */\nexport type GitHubRepoChangeParams = RepositoryChangeLaunchParams<\n\tGitHubRepoChangeCommonParams & (GitHubIssueOriginParams | GitHubUiOriginParams)\n>;\n\n/** @public */\nexport function isIssueOrigin(\n\tparams: GitHubRepoChangeParams,\n): params is GitHubRepoChangeParams & GitHubIssueOriginParams {\n\treturn params.origin === \"issue\";\n}\n\n/** @public */\nexport const githubRepoChangeParamsCodec =\n\tcreateRepositoryChangeParamsCodec<GitHubRepoChangeParams>({\n\t\tnormalize(value) {\n\t\t\treturn normalizeRepositoryIssueChangeParams(value, \"GitHub Repo Change\", [\n\t\t\t\t\"githubProfile\",\n\t\t\t\t\"sshCredentialRef\",\n\t\t\t\t\"owner\",\n\t\t\t\t\"repo\",\n\t\t\t]);\n\t\t},\n\t});\n","import { parseRepositoryProfileBindings } from \"@leitwerk-dev/coding/repository-change-launch\";\n\n/** Server-owned, non-secret wiring for future launches. */\n/** @public */\nexport interface ProfileBinding {\n\t/** @public */\n\tsshCredentialRef: string;\n}\n/** @public */\nexport type ProfileBindings = Readonly<Record<string, Readonly<ProfileBinding>>>;\n\n/** @public */\nexport function parseProfileBindings(raw: unknown): ProfileBindings {\n\treturn parseRepositoryProfileBindings(raw, \"github-repo-change\", {\n\t\tsshCredentialRef: \"ssh_credential_ref\",\n\t});\n}\n/** @public */\nexport function resolveProfileBinding(bindings: ProfileBindings, profile: string): ProfileBinding {\n\treturn Object.hasOwn(bindings, profile)\n\t\t? { ...bindings[profile] }\n\t\t: { sshCredentialRef: profile };\n}\n","import { createRepositoryChangeProcess } from \"@leitwerk-dev/coding\";\nimport {\n\tcreateRepositoryChangePublication,\n\tpublicationObject as object,\n\ttype PublicationSource,\n\ttype PublicationState,\n\tpullRequestPublicationCallbacks,\n\tpullRequestPublicationSources,\n\treadPublicationState,\n\treconcilePullRequestSourceIssue,\n\tresolvePullRequestGitIdentity,\n} from \"@leitwerk-dev/coding/repository-change-publication\";\nimport type { RepositoryChangeState } from \"@leitwerk-dev/coding/repository-change-state\";\nimport { githubExternal, githubIssueWatcherSource } from \"@leitwerk-dev/github\";\nimport type { createGitHubRepoChangeLauncher } from \"./launcher.js\";\nimport {\n\ttype GitHubRepoChangeParams,\n\tgithubRepoChangeParamsCodec,\n\tisIssueOrigin,\n} from \"./params.js\";\n\nconst processId = \"github_repo_change_process\";\nconst ids = {\n\tdeliver: \"deliver_change\",\n\tfeedback: \"revise_from_pull_request_feedback\",\n\tciRepair: \"repair_github_checks\",\n\toperator: \"ci_operator_action\",\n};\nconst remote = (state: RepositoryChangeState) => readPublicationState(state, \"githubRepoChange\");\n\nconst deliveryTools = [\n\t\"github_get_pull_request\",\n\t\"github_add_pull_request_comment\",\n\t\"github_resolve_git_identity\",\n\t\"github_ensure_pull_request\",\n\t\"github_add_issue_comment\",\n\t\"github_add_pull_request_feedback_reaction\",\n\t\"github_reply_to_pull_request_feedback\",\n\t\"github_get_issue\",\n\t\"github_ensure_label\",\n\t\"github_update_issue\",\n] as const;\n\n/** @public */\nexport function createGitHubRepoChangeProcess(\n\tlauncher: ReturnType<typeof createGitHubRepoChangeLauncher>,\n\tdocker: boolean,\n) {\n\tconst sharedSources = pullRequestPublicationSources<GitHubRepoChangeParams>(\n\t\t\"github\",\n\t\t\"GitHub\",\n\t\tgithubExternal,\n\t\t(params) => params.githubProfile,\n\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t);\n\tconst { requirePr } = sharedSources;\n\tconst failedPipeline = githubExternal.checks<GitHubRepoChangeParams, RepositoryChangeState>(\n\t\t({ params, state }) => ({\n\t\t\tprofile: params.githubProfile,\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\theadSha: requirePr(state).headSha,\n\t\t\tafterKey: remote(state).pipeline?.evidenceKey as string | undefined,\n\t\t}),\n\t);\n\n\tconst sources: PublicationSource<GitHubRepoChangeParams>[] = [\n\t\t{\n\t\t\tid: \"github_merge_conflict\",\n\t\t\tkind: \"conflict\",\n\t\t\tlabel: \"Rebase conflicting pull request\",\n\t\t\tsource: githubExternal.pullRequestState(({ params, state }) => ({\n\t\t\t\tprofile: params.githubProfile,\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\t\theadSha: requirePr(state).headSha,\n\t\t\t\tlastConflictKey: remote(state).lastConflictKey,\n\t\t\t\tfeedbackCursor: 0,\n\t\t\t\teventKinds: [\"merge_conflict\"],\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t})),\n\t\t\tread: ({ event }) => ({\n\t\t\t\tkind: \"conflict\",\n\t\t\t\tconflict: object(event).conflict as NonNullable<PublicationState[\"conflict\"]>,\n\t\t\t}),\n\t\t},\n\t\tsharedSources.feedback,\n\t\t{\n\t\t\tid: \"github_failure_repair\",\n\t\t\toperatorId: \"github_failure_operator\",\n\t\t\tkind: \"failure\",\n\t\t\tlabel: \"Repair failed GitHub checks\",\n\t\t\tsource: failedPipeline,\n\t\t\tread: ({ state, event }) => {\n\t\t\t\tconst checks = object(object(event).checks);\n\t\t\t\tconst current = requirePr(state);\n\t\t\t\tif (checks.headSha !== current.headSha) throw new Error(\"Stale GitHub check evidence\");\n\t\t\t\tconst failed = Array.isArray(checks.failed) ? checks.failed : [];\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"failure\",\n\t\t\t\t\tpipeline: {\n\t\t\t\t\t\tnumber: 0,\n\t\t\t\t\t\tstatus: \"failure\",\n\t\t\t\t\t\t...checks,\n\t\t\t\t\t\tevidenceKey: `${checks.headSha}:${failed.map((run) => object(run).url).join(\":\")}`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t...sharedSources.terminal,\n\t\tsharedSources.cancelled,\n\t];\n\tconst publicationConfig = createRepositoryChangePublication<GitHubRepoChangeParams>({\n\t\tnamespace: \"githubRepoChange\",\n\t\tlabel: \"GitHub PR\",\n\t\tids,\n\t\tsources,\n\t\ttools: {\n\t\t\tdelivery: deliveryTools,\n\t\t\tfeedback: [\"github_get_pull_request\", \"github_list_pull_request_feedback\"],\n\t\t\tci: [\"github_get_ci_diagnostics\"],\n\t\t},\n\t\tidentity: (ctx) => resolvePullRequestGitIdentity(ctx, \"github\", ctx.params.githubProfile),\n\t\treconcileTerminal: reconcilePullRequestSourceIssue<GitHubRepoChangeParams>(\n\t\t\t\"github\",\n\t\t\t\"name\",\n\t\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t\t),\n\t\t...pullRequestPublicationCallbacks<GitHubRepoChangeParams>(\"github\", \"GitHub\", (params) =>\n\t\t\tisIssueOrigin(params) ? params : undefined,\n\t\t),\n\t\tcommitMessage: (kind) =>\n\t\t\tkind === \"feedback\" ? \"fix: address GitHub review feedback\" : \"fix: repair GitHub checks\",\n\t\tprompt(kind, current) {\n\t\t\treturn kind === \"feedback\"\n\t\t\t\t? `Address the unseen GitHub pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use GitHub tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.`\n\t\t\t\t: `Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`;\n\t\t},\n\t});\n\tconst publication = publicationConfig.fragment;\n\tpublication.watcher({\n\t\tid: \"use_leitwerk\",\n\t\tlabel: \"GitHub use-leitwerk issues\",\n\t\tdescription: \"Launch a remote repository change for GitHub issues carrying the trigger label\",\n\t\tsource: githubIssueWatcherSource,\n\t\tpreparationChecks: launcher.preparationChecks,\n\t\tresolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,\n\t});\n\n\tconst definition = createRepositoryChangeProcess<GitHubRepoChangeParams>({\n\t\tprocessId,\n\t\tdisplayName: \"GitHub Repo Change\",\n\t\tparamsCodec: githubRepoChangeParamsCodec,\n\t\tlauncher: launcher.launcher,\n\t\tfinalizeLabel: \"Publish pull request\",\n\t\tfinalizeForm: {\n\t\t\tid: \"github_publish\",\n\t\t\ttitle: \"Publish pull request\",\n\t\t\tfields: [],\n\t\t\tsubmitLabel: \"Publish\",\n\t\t},\n\t\trepositoryCredentials: ({ params }) => [\n\t\t\t{\n\t\t\t\tprojectKey: \"repo\",\n\t\t\t\tkind: \"git_ssh\",\n\t\t\t\tcredentialRef: params.sshCredentialRef,\n\t\t\t},\n\t\t],\n\t\tpublication: publicationConfig,\n\t});\n\n\tdefinition.process.runtime = { ...definition.process.runtime, docker };\n\n\treturn definition.process;\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;;;ACDlC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAA4D;;;ACJrE;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AA0BA,SAAS,cACf,QAC6D;AAC7D,SAAO,OAAO,W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IAAI,MAAM,mDAAmD;AACpE,eAAS,UAAU;AAAA,QAClB;AAAA,QACA;AAAA,QACA,iBAAiB,qBAAqB,MAAM;AAAA,MAC7C,CAAC;AACD,UAAI,OAAO,MAAM,SAAS,UAAU,IAAI,CAAC;AAAA,IAC1C;AAAA,EACD;AAGA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EACD;AACD;AAOO,IAAM;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,UAAU;AACX,IAAI,uBAAuB,EAAE,QAAQ,KAAK,CAAC;AAEpC,IAAM;AAAA,EACZ,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,UAAU;AACX,IAAI;AACJ,IAAO,gBAAQ;","names":["configureGitHubRepoChangeLauncher","githubRepositoryPreparationChecks","resolveGitHubGitIdentity","githubRepoChangeUiLauncher"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/launcher.ts","../src/params.ts","../src/profile-bindings.ts","../src/process.ts"],"sourcesContent":["import { gitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport { type GitHubGitIdentity, githubIntegration } from \"@leitwerk-dev/github\";\nimport type {\n\tLaunchPreparationCheck,\n\tLeitwerkExtensionModule,\n\tProcessLaunchConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createGitHubRepoChangeLauncher, type LauncherDependencies } from \"./launcher.js\";\nimport type { GitHubRepoChangeParams } from \"./params.js\";\nimport { createGitHubRepoChangeProcess } from \"./process.js\";\nimport { parseProfileBindings } from \"./profile-bindings.js\";\n\n/** @public */\nexport const manifest = {\n\t/** @public */\n\tid: \"github-repo-change\",\n\t/** @public */\n\tversion: \"0.1.9\",\n\t/** @public */\n\trequires: [\"github\", \"coding\", \"git-ssh\"],\n} as const;\n\n/** Load exactly one variant per catalog. Only trusted composition code selects Docker. */\n/** @public */\n/** @public */\nexport function createGitHubRepoChange(options: {\n\t/** @public */\n\tdocker: boolean;\n}) {\n\tif (typeof options.docker !== \"boolean\") throw new Error(\"docker must be a boolean\");\n\tconst launcher = createGitHubRepoChangeLauncher();\n\tconst process = createGitHubRepoChangeProcess(launcher, options.docker);\n\tconst extension: LeitwerkExtensionModule = {\n\t\tmanifest,\n\t\tsetupCatalog(api) {\n\t\t\tapi.registerProcess(process);\n\t\t},\n\t\tsetupServer(api, config) {\n\t\t\tconst github = api.require(githubIntegration);\n\t\t\tconst gitSsh = api.require(gitSshIntegration);\n\t\t\tif (Array.isArray(github) || Array.isArray(gitSsh))\n\t\t\t\tthrow new Error(\"Repository delivery integrations must be singular\");\n\t\t\tlauncher.configure({\n\t\t\t\tgithub,\n\t\t\t\tgitSsh,\n\t\t\t\tprofileBindings: parseProfileBindings(config),\n\t\t\t});\n\t\t\tapi.onStop(() => launcher.configure(null));\n\t\t},\n\t};\n\t/** @public */\n\t/** @public */\n\treturn {\n\t\t/** @public */\n\t\textension,\n\t\t/** @public */\n\t\tprocess,\n\t\t/** @public */\n\t\tlauncher,\n\t};\n}\n\nexport * from \"./launcher.js\";\nexport * from \"./params.js\";\nexport * from \"./process.js\";\nexport * from \"./profile-bindings.js\";\n/** @public */\nexport const {\n\textension: defaultExtension,\n\tprocess: githubRepoChangeProcess,\n\tlauncher: defaultGitHubRepoChangeLauncher,\n} = createGitHubRepoChange({ docker: true });\n/** @public */\nexport const configureGitHubRepoChangeLauncher: (value: LauncherDependencies | null) => void =\n\tdefaultGitHubRepoChangeLauncher.configure;\n/** @public */\nexport const githubRepositoryPreparationChecks: (\n\tinput: unknown,\n\tlaunch: ProcessLaunchConfig<GitHubRepoChangeParams>,\n) => readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] =\n\tdefaultGitHubRepoChangeLauncher.preparationChecks;\n/** @public */\nexport const resolveGitHubGitIdentity: (profile: string) => Promise<GitHubGitIdentity> =\n\tdefaultGitHubRepoChangeLauncher.resolveGitIdentity;\n/** @public */\nexport const githubRepoChangeUiLauncher = defaultGitHubRepoChangeLauncher.launcher;\nexport default defaultExtension;\n","import {\n\tcreateRepositoryChangeLauncher,\n\ttype PullRequestChangeLaunchInput,\n\trepositoryIssueChangeLaunchConfig,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\nimport { createGitSshPreparationCheck, type GitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from \"@leitwerk-dev/github\";\nimport type { ProcessLaunchConfig } from \"@leitwerk-dev/process-sdk\";\nimport { type GitHubRepoChangeParams, isIssueOrigin } from \"./params.js\";\nimport { type ProfileBindings, resolveProfileBinding } from \"./profile-bindings.js\";\n\n/** @public */\nexport const githubRepoChangeUiLauncherId = \"github_repo_change_process.ui_launcher\" as const;\n\n/** @public */\nexport function githubRepoChangeParams(\n\trepository: GitHubRepository,\n\tinput: PullRequestChangeLaunchInput,\n): GitHubRepoChangeParams {\n\treturn {\n\t\trepoLocator: repository.ssh_url,\n\t\tbaseBranch: repository.default_branch,\n\t\tworkBranch: input.workBranch,\n\t\tprompt: input.prompt,\n\t\tgithubProfile: input.profile,\n\t\tsshCredentialRef: input.sshCredentialRef,\n\t\towner: repository.owner.login,\n\t\trepo: repository.name,\n\t\torigin: \"ui\",\n\t\tissueNumber: null,\n\t\tissueUrl: null,\n\t\ttriggerLabel: null,\n\t\tdoneLabel: null,\n\t};\n}\n\n/** @public */\nexport function githubRepoChangeLaunchConfig(\n\tparams: GitHubRepoChangeParams,\n\ttitle: string,\n\tgitIdentity: GitHubGitIdentity,\n\trepository?: GitHubRepository,\n): ProcessLaunchConfig<GitHubRepoChangeParams> {\n\tconst { owner, repo, githubProfile: profile } = params;\n\tconst issue = isIssueOrigin(params);\n\treturn repositoryIssueChangeLaunchConfig(\n\t\t\"github\",\n\t\tparams,\n\t\ttitle,\n\t\t`${owner}/${repo}`,\n\t\t{\n\t\t\tgithub: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },\n\t\t\t\"leitwerk.gitIdentity\": gitIdentity,\n\t\t},\n\t\trepository,\n\t);\n}\n\n/** @public */\nexport interface LauncherDependencies {\n\t/** @public */\n\tgithub: GitHubIntegration;\n\t/** @public */\n\tgitSsh: GitSshIntegration;\n\t/** @public */\n\tprofileBindings?: ProfileBindings;\n}\n\n/** @public */\nexport function createGitHubRepoChangeLauncher() {\n\treturn createRepositoryChangeLauncher({\n\t\tid: githubRepoChangeUiLauncherId,\n\t\tprovider: \"GitHub\",\n\t\tproviderId: \"github\",\n\t\tintegration: (deps: LauncherDependencies) => deps.github,\n\t\tprofile: (params: GitHubRepoChangeParams) => params.githubProfile,\n\t\tparams: githubRepoChangeParams,\n\t\tlaunchConfig: githubRepoChangeLaunchConfig,\n\t\tresolveProfiles(profile, { gitSsh, profileBindings = {} }) {\n\t\t\tconst binding = resolveProfileBinding(profileBindings, profile);\n\t\t\tif (!gitSsh.profiles().includes(binding.sshCredentialRef))\n\t\t\t\tthrow new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);\n\t\t\treturn binding;\n\t\t},\n\t\tpreparationChecks: (params, dependencies) => [\n\t\t\tcreateGitSshPreparationCheck(\"write\", params, () => dependencies().gitSsh),\n\t\t],\n\t});\n}\n","import {\n\tcreateRepositoryChangeParamsCodec,\n\tnormalizeRepositoryIssueChangeParams,\n\ttype RepositoryChangeLaunchParams,\n\ttype RepositoryIssueOriginParams,\n\ttype RepositoryUiOriginParams,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\n\n/** @public */\ninterface GitHubRepoChangeCommonParams {\n\t/** @public */\n\tgithubProfile: string;\n\t/** @public */\n\tsshCredentialRef: string;\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n}\n\n/** @public */\nexport interface GitHubIssueOriginParams extends RepositoryIssueOriginParams {}\n\n/** @public */\nexport interface GitHubUiOriginParams extends RepositoryUiOriginParams {}\n\n/** @public */\nexport type GitHubRepoChangeParams = RepositoryChangeLaunchParams<\n\tGitHubRepoChangeCommonParams & (GitHubIssueOriginParams | GitHubUiOriginParams)\n>;\n\n/** @public */\nexport function isIssueOrigin(\n\tparams: GitHubRepoChangeParams,\n): params is GitHubRepoChangeParams & GitHubIssueOriginParams {\n\treturn params.origin === \"issue\";\n}\n\n/** @public */\nexport const githubRepoChangeParamsCodec =\n\tcreateRepositoryChangeParamsCodec<GitHubRepoChangeParams>({\n\t\tnormalize(value) {\n\t\t\treturn normalizeRepositoryIssueChangeParams(value, \"GitHub Repo Change\", [\n\t\t\t\t\"githubProfile\",\n\t\t\t\t\"sshCredentialRef\",\n\t\t\t\t\"owner\",\n\t\t\t\t\"repo\",\n\t\t\t]);\n\t\t},\n\t});\n","import { parseRepositoryProfileBindings } from \"@leitwerk-dev/coding/repository-change-launch\";\n\n/** Server-owned, non-secret wiring for future launches. */\n/** @public */\nexport interface ProfileBinding {\n\t/** @public */\n\tsshCredentialRef: string;\n}\n/** @public */\nexport type ProfileBindings = Readonly<Record<string, Readonly<ProfileBinding>>>;\n\n/** @public */\nexport function parseProfileBindings(raw: unknown): ProfileBindings {\n\treturn parseRepositoryProfileBindings(raw, \"github-repo-change\", {\n\t\tsshCredentialRef: \"ssh_credential_ref\",\n\t});\n}\n/** @public */\nexport function resolveProfileBinding(bindings: ProfileBindings, profile: string): ProfileBinding {\n\treturn Object.hasOwn(bindings, profile)\n\t\t? { ...bindings[profile] }\n\t\t: { sshCredentialRef: profile };\n}\n","import {\n\tcreatePullRequestChangeProcess,\n\tpublicationObject as object,\n\ttype PublicationSource,\n\tpullRequestPublicationDefaults,\n\treadPublicationState,\n} from \"@leitwerk-dev/coding/repository-change-publication\";\nimport type { RepositoryChangeState } from \"@leitwerk-dev/coding/repository-change-state\";\nimport { githubExternal, githubIssueWatcherSource } from \"@leitwerk-dev/github\";\nimport type { createGitHubRepoChangeLauncher } from \"./launcher.js\";\nimport {\n\ttype GitHubRepoChangeParams,\n\tgithubRepoChangeParamsCodec,\n\tisIssueOrigin,\n} from \"./params.js\";\n\nconst remote = (state: RepositoryChangeState) => readPublicationState(state, \"githubRepoChange\");\n\n/** @public */\nexport function createGitHubRepoChangeProcess(\n\tlauncher: ReturnType<typeof createGitHubRepoChangeLauncher>,\n\tdocker: boolean,\n) {\n\tconst sharedSources = pullRequestPublicationDefaults<GitHubRepoChangeParams>(\n\t\t\"github\",\n\t\t\"GitHub\",\n\t\tgithubExternal,\n\t\t(params) => params.githubProfile,\n\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t\t\"name\",\n\t\t{\n\t\t\tid: \"repair_github_checks\",\n\t\t\tlabel: \"GitHub checks\",\n\t\t\ttools: [\"github_get_ci_diagnostics\"],\n\t\t\tprompt: (current) =>\n\t\t\t\t`Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`,\n\t\t},\n\t);\n\tconst { requirePr } = sharedSources;\n\tconst failedPipeline = githubExternal.checks<GitHubRepoChangeParams, RepositoryChangeState>(\n\t\t({ params, state }) => ({\n\t\t\tprofile: params.githubProfile,\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\theadSha: requirePr(state).headSha,\n\t\t\tafterKey: remote(state).pipeline?.evidenceKey as string | undefined,\n\t\t}),\n\t);\n\n\tconst sources: PublicationSource<GitHubRepoChangeParams>[] = [\n\t\tsharedSources.conflict(\n\t\t\tgithubExternal.pullRequestState(({ params, state }) => ({\n\t\t\t\tprofile: params.githubProfile,\n\t\t\t\towner: params.owner,\n\t\t\t\trepo: params.repo,\n\t\t\t\tprNumber: requirePr(state).prNumber,\n\t\t\t\theadSha: requirePr(state).headSha,\n\t\t\t\tlastConflictKey: remote(state).lastConflictKey,\n\t\t\t\tfeedbackCursor: 0,\n\t\t\t\teventKinds: [\"merge_conflict\"],\n\t\t\t\tpollInterval: \"30s\",\n\t\t\t})),\n\t\t),\n\t\tsharedSources.feedback,\n\t\t{\n\t\t\tid: \"github_failure_repair\",\n\t\t\toperatorId: \"github_failure_operator\",\n\t\t\tkind: \"failure\",\n\t\t\tlabel: \"Repair failed GitHub checks\",\n\t\t\tsource: failedPipeline,\n\t\t\tread: ({ state, event }) => {\n\t\t\t\tconst checks = object(object(event).checks);\n\t\t\t\tconst current = requirePr(state);\n\t\t\t\tif (checks.headSha !== current.headSha) throw new Error(\"Stale GitHub check evidence\");\n\t\t\t\tconst failed = Array.isArray(checks.failed) ? checks.failed : [];\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"failure\",\n\t\t\t\t\tpipeline: {\n\t\t\t\t\t\tnumber: 0,\n\t\t\t\t\t\tstatus: \"failure\",\n\t\t\t\t\t\t...checks,\n\t\t\t\t\t\tevidenceKey: `${checks.headSha}:${failed.map((run) => object(run).url).join(\":\")}`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t...sharedSources.terminal,\n\t\tsharedSources.cancelled,\n\t];\n\treturn createPullRequestChangeProcess(\"github\", \"GitHub\", docker, {\n\t\tparamsCodec: githubRepoChangeParamsCodec,\n\t\tlauncher: launcher.launcher,\n\t\tworkflow: launcher.workflow,\n\t\tpublication: { ...sharedSources.adapter, sources },\n\t\twatcher: {\n\t\t\tsource: githubIssueWatcherSource,\n\t\t\tpreparationChecks: launcher.preparationChecks,\n\t\t\tresolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,\n\t\t},\n\t});\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAiC,yBAAyB;;;ACD1D;AAAA,EACC;AAAA,EAEA;AAAA,OACM;AACP,SAAS,oCAA4D;;;ACLrE;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AA0BA,SAAS,cACf,QAC6D;AAC7D,SAAO,OAAO,WAAW;AAC1B;AAGO,IAAM,8BACZ,kCAA0D;AAAA,EACz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B,gCAAgC;AAC1E,IAAO,gBAAQ;","names":[]}
|
package/dist/launcher.d.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
+
import { type PullRequestChangeLaunchInput } from "@leitwerk-dev/coding/repository-change-launch";
|
|
1
2
|
import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
2
3
|
import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
|
|
3
|
-
import type {
|
|
4
|
+
import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
|
|
4
5
|
import { type GitHubRepoChangeParams } from "./params.js";
|
|
5
6
|
import { type ProfileBindings } from "./profile-bindings.js";
|
|
6
7
|
/** @public */
|
|
7
8
|
export declare const githubRepoChangeUiLauncherId: "github_repo_change_process.ui_launcher";
|
|
8
9
|
/** @public */
|
|
9
|
-
export declare function githubRepoChangeParams(repository: GitHubRepository, input:
|
|
10
|
-
/** @public */
|
|
11
|
-
profile: string;
|
|
12
|
-
/** @public */
|
|
13
|
-
sshCredentialRef: string;
|
|
14
|
-
/** @public */
|
|
15
|
-
prompt: string;
|
|
16
|
-
/** @public */
|
|
17
|
-
workBranch: string;
|
|
18
|
-
}): GitHubRepoChangeParams;
|
|
10
|
+
export declare function githubRepoChangeParams(repository: GitHubRepository, input: PullRequestChangeLaunchInput): GitHubRepoChangeParams;
|
|
19
11
|
/** @public */
|
|
20
|
-
export declare function githubRepoChangeLaunchConfig(params: GitHubRepoChangeParams, title: string, gitIdentity: GitHubGitIdentity): ProcessLaunchConfig<GitHubRepoChangeParams>;
|
|
12
|
+
export declare function githubRepoChangeLaunchConfig(params: GitHubRepoChangeParams, title: string, gitIdentity: GitHubGitIdentity, repository?: GitHubRepository): ProcessLaunchConfig<GitHubRepoChangeParams>;
|
|
21
13
|
/** @public */
|
|
22
14
|
export interface LauncherDependencies {
|
|
23
15
|
/** @public */
|
|
@@ -29,15 +21,15 @@ export interface LauncherDependencies {
|
|
|
29
21
|
}
|
|
30
22
|
/** @public */
|
|
31
23
|
export declare function createGitHubRepoChangeLauncher(): {
|
|
32
|
-
/** @
|
|
33
|
-
configure
|
|
34
|
-
/** @
|
|
35
|
-
preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) =>
|
|
36
|
-
/** @
|
|
24
|
+
/** @internal */
|
|
25
|
+
configure(value: LauncherDependencies | null): void;
|
|
26
|
+
/** @internal */
|
|
27
|
+
preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitHubRepoChangeParams>) => import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<GitHubRepoChangeParams>[];
|
|
28
|
+
/** @internal */
|
|
37
29
|
resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
|
|
38
|
-
/** @
|
|
30
|
+
/** @internal */
|
|
39
31
|
resolveGitIdentity: (profile: string) => Promise<GitHubGitIdentity>;
|
|
40
|
-
/** @
|
|
32
|
+
/** @internal */
|
|
41
33
|
launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<GitHubRepoChangeParams> & {
|
|
42
34
|
/** @internal */
|
|
43
35
|
resolveIssueLaunchConfig(event: {
|
|
@@ -51,5 +43,7 @@ export declare function createGitHubRepoChangeLauncher(): {
|
|
|
51
43
|
labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
|
|
52
44
|
}): Promise<ProcessLaunchConfig<GitHubRepoChangeParams>>;
|
|
53
45
|
};
|
|
46
|
+
/** @internal */
|
|
47
|
+
workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<GitHubRepoChangeParams>;
|
|
54
48
|
};
|
|
55
49
|
//# sourceMappingURL=launcher.d.ts.map
|
package/dist/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,4BAA4B,EAEjC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,KAAK,sBAAsB,EAAiB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,uBAAuB,CAAC;AAEpF,cAAc;AACd,eAAO,MAAM,4BAA4B,EAAG,wCAAiD,CAAC;AAE9F,cAAc;AACd,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,4BAA4B,GACjC,sBAAsB,CAgBxB;AAED,cAAc;AACd,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,iBAAiB,EAC9B,UAAU,CAAC,EAAE,gBAAgB,GAC3B,mBAAmB,CAAC,sBAAsB,CAAC,CAc7C;AAED,cAAc;AACd,MAAM,WAAW,oBAAoB;IACpC,cAAc;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc;IACd,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,cAAc;AACd,wBAAgB,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;EAmB7C"}
|
package/dist/process.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACN,KAAK,sBAAsB,EAG3B,MAAM,aAAa,CAAC;AAIrB,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,iHAgFf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/github-repo-change",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"leitwerk": {
|
|
6
6
|
"extension": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@leitwerk-dev/coding": "0.
|
|
24
|
-
"@leitwerk-dev/external-writes": "0.
|
|
25
|
-
"@leitwerk-dev/git-ssh": "0.
|
|
26
|
-
"@leitwerk-dev/process-sdk": "0.
|
|
27
|
-
"@leitwerk-dev/github": "0.
|
|
23
|
+
"@leitwerk-dev/coding": "0.4.0",
|
|
24
|
+
"@leitwerk-dev/external-writes": "0.4.0",
|
|
25
|
+
"@leitwerk-dev/git-ssh": "0.4.0",
|
|
26
|
+
"@leitwerk-dev/process-sdk": "0.4.0",
|
|
27
|
+
"@leitwerk-dev/github": "0.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"tsup": "^8.5.1"
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { gitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
2
|
-
import { githubIntegration } from "@leitwerk-dev/github";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import { type GitHubGitIdentity, githubIntegration } from "@leitwerk-dev/github";
|
|
3
|
+
import type {
|
|
4
|
+
LaunchPreparationCheck,
|
|
5
|
+
LeitwerkExtensionModule,
|
|
6
|
+
ProcessLaunchConfig,
|
|
7
|
+
} from "@leitwerk-dev/process-sdk";
|
|
8
|
+
import { createGitHubRepoChangeLauncher, type LauncherDependencies } from "./launcher.js";
|
|
9
|
+
import type { GitHubRepoChangeParams } from "./params.js";
|
|
5
10
|
import { createGitHubRepoChangeProcess } from "./process.js";
|
|
6
11
|
import { parseProfileBindings } from "./profile-bindings.js";
|
|
7
12
|
|
|
@@ -66,10 +71,17 @@ export const {
|
|
|
66
71
|
launcher: defaultGitHubRepoChangeLauncher,
|
|
67
72
|
} = createGitHubRepoChange({ docker: true });
|
|
68
73
|
/** @public */
|
|
69
|
-
export const
|
|
70
|
-
configure
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
export const configureGitHubRepoChangeLauncher: (value: LauncherDependencies | null) => void =
|
|
75
|
+
defaultGitHubRepoChangeLauncher.configure;
|
|
76
|
+
/** @public */
|
|
77
|
+
export const githubRepositoryPreparationChecks: (
|
|
78
|
+
input: unknown,
|
|
79
|
+
launch: ProcessLaunchConfig<GitHubRepoChangeParams>,
|
|
80
|
+
) => readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] =
|
|
81
|
+
defaultGitHubRepoChangeLauncher.preparationChecks;
|
|
82
|
+
/** @public */
|
|
83
|
+
export const resolveGitHubGitIdentity: (profile: string) => Promise<GitHubGitIdentity> =
|
|
84
|
+
defaultGitHubRepoChangeLauncher.resolveGitIdentity;
|
|
85
|
+
/** @public */
|
|
86
|
+
export const githubRepoChangeUiLauncher = defaultGitHubRepoChangeLauncher.launcher;
|
|
75
87
|
export default defaultExtension;
|
package/src/launcher.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
createRepositoryChangeLauncher,
|
|
3
|
+
type PullRequestChangeLaunchInput,
|
|
4
|
+
repositoryIssueChangeLaunchConfig,
|
|
4
5
|
} from "@leitwerk-dev/coding/repository-change-launch";
|
|
5
6
|
import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
|
|
6
7
|
import type { GitHubGitIdentity, GitHubIntegration, GitHubRepository } from "@leitwerk-dev/github";
|
|
7
|
-
import type {
|
|
8
|
+
import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
|
|
8
9
|
import { type GitHubRepoChangeParams, isIssueOrigin } from "./params.js";
|
|
9
10
|
import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
|
|
10
11
|
|
|
@@ -14,16 +15,7 @@ export const githubRepoChangeUiLauncherId = "github_repo_change_process.ui_launc
|
|
|
14
15
|
/** @public */
|
|
15
16
|
export function githubRepoChangeParams(
|
|
16
17
|
repository: GitHubRepository,
|
|
17
|
-
input:
|
|
18
|
-
/** @public */
|
|
19
|
-
profile: string;
|
|
20
|
-
/** @public */
|
|
21
|
-
sshCredentialRef: string;
|
|
22
|
-
/** @public */
|
|
23
|
-
prompt: string;
|
|
24
|
-
/** @public */
|
|
25
|
-
workBranch: string;
|
|
26
|
-
},
|
|
18
|
+
input: PullRequestChangeLaunchInput,
|
|
27
19
|
): GitHubRepoChangeParams {
|
|
28
20
|
return {
|
|
29
21
|
repoLocator: repository.ssh_url,
|
|
@@ -47,34 +39,21 @@ export function githubRepoChangeLaunchConfig(
|
|
|
47
39
|
params: GitHubRepoChangeParams,
|
|
48
40
|
title: string,
|
|
49
41
|
gitIdentity: GitHubGitIdentity,
|
|
42
|
+
repository?: GitHubRepository,
|
|
50
43
|
): ProcessLaunchConfig<GitHubRepoChangeParams> {
|
|
51
44
|
const { owner, repo, githubProfile: profile } = params;
|
|
52
45
|
const issue = isIssueOrigin(params);
|
|
53
|
-
return
|
|
54
|
-
|
|
46
|
+
return repositoryIssueChangeLaunchConfig(
|
|
47
|
+
"github",
|
|
55
48
|
params,
|
|
56
49
|
title,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
? {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
projects: [
|
|
65
|
-
{
|
|
66
|
-
key: "repo",
|
|
67
|
-
repoLocator: params.repoLocator,
|
|
68
|
-
baseBranch: params.baseBranch,
|
|
69
|
-
workBranch: params.workBranch,
|
|
70
|
-
...(issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {}),
|
|
71
|
-
metadata: {
|
|
72
|
-
github: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
|
|
73
|
-
"leitwerk.gitIdentity": gitIdentity,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
};
|
|
50
|
+
`${owner}/${repo}`,
|
|
51
|
+
{
|
|
52
|
+
github: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
|
|
53
|
+
"leitwerk.gitIdentity": gitIdentity,
|
|
54
|
+
},
|
|
55
|
+
repository,
|
|
56
|
+
);
|
|
78
57
|
}
|
|
79
58
|
|
|
80
59
|
/** @public */
|
|
@@ -89,83 +68,22 @@ export interface LauncherDependencies {
|
|
|
89
68
|
|
|
90
69
|
/** @public */
|
|
91
70
|
export function createGitHubRepoChangeLauncher() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/** @public */
|
|
95
|
-
function configureGitHubRepoChangeLauncher(value: LauncherDependencies | null): void {
|
|
96
|
-
dependencies = value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function requireDependencies(): LauncherDependencies {
|
|
100
|
-
if (!dependencies) throw new Error("GitHub repository launcher is not configured");
|
|
101
|
-
return dependencies;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** @public */
|
|
105
|
-
function githubRepositoryPreparationChecks(
|
|
106
|
-
_input: unknown,
|
|
107
|
-
{ params }: ProcessLaunchConfig<GitHubRepoChangeParams>,
|
|
108
|
-
): readonly LaunchPreparationCheck<GitHubRepoChangeParams>[] {
|
|
109
|
-
return [
|
|
110
|
-
repositoryVisibilityCheck("GitHub", async () =>
|
|
111
|
-
(await repositories(params.githubProfile)).some(
|
|
112
|
-
(candidate) => candidate.full_name === `${params.owner}/${params.repo}`,
|
|
113
|
-
),
|
|
114
|
-
),
|
|
115
|
-
createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
|
|
116
|
-
createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh),
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** @public */
|
|
121
|
-
function resolveProfiles(profile: string) {
|
|
122
|
-
const { github, gitSsh, profileBindings = {} } = requireDependencies();
|
|
123
|
-
if (!(github.profiles?.() ?? []).includes(profile))
|
|
124
|
-
throw new Error("GitHub profile is not available");
|
|
125
|
-
const binding = resolveProfileBinding(profileBindings, profile);
|
|
126
|
-
|
|
127
|
-
if (!gitSsh.profiles().includes(binding.sshCredentialRef))
|
|
128
|
-
throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
|
|
129
|
-
return binding;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** @public */
|
|
133
|
-
async function resolveGitHubGitIdentity(profile: string): Promise<GitHubGitIdentity> {
|
|
134
|
-
if (!profile) throw new Error("A GitHub profile is required to resolve Git identity");
|
|
135
|
-
return requireDependencies().github.client(profile).resolveGitIdentity(profile);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function repositories(profile: string): Promise<readonly GitHubRepository[]> {
|
|
139
|
-
if (!profile) return [];
|
|
140
|
-
const { github } = requireDependencies();
|
|
141
|
-
if (!(github.profiles?.() ?? []).includes(profile)) return [];
|
|
142
|
-
return github.client(profile).listRepositories();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const githubRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
|
|
71
|
+
return createRepositoryChangeLauncher({
|
|
146
72
|
id: githubRepoChangeUiLauncherId,
|
|
147
73
|
provider: "GitHub",
|
|
148
74
|
providerId: "github",
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
repositories,
|
|
152
|
-
resolveProfiles,
|
|
153
|
-
resolveGitIdentity: resolveGitHubGitIdentity,
|
|
75
|
+
integration: (deps: LauncherDependencies) => deps.github,
|
|
76
|
+
profile: (params: GitHubRepoChangeParams) => params.githubProfile,
|
|
154
77
|
params: githubRepoChangeParams,
|
|
155
78
|
launchConfig: githubRepoChangeLaunchConfig,
|
|
156
|
-
|
|
79
|
+
resolveProfiles(profile, { gitSsh, profileBindings = {} }) {
|
|
80
|
+
const binding = resolveProfileBinding(profileBindings, profile);
|
|
81
|
+
if (!gitSsh.profiles().includes(binding.sshCredentialRef))
|
|
82
|
+
throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
|
|
83
|
+
return binding;
|
|
84
|
+
},
|
|
85
|
+
preparationChecks: (params, dependencies) => [
|
|
86
|
+
createGitSshPreparationCheck("write", params, () => dependencies().gitSsh),
|
|
87
|
+
],
|
|
157
88
|
});
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
/** @public */
|
|
161
|
-
configure: configureGitHubRepoChangeLauncher,
|
|
162
|
-
/** @public */
|
|
163
|
-
preparationChecks: githubRepositoryPreparationChecks,
|
|
164
|
-
/** @public */
|
|
165
|
-
resolveProfiles,
|
|
166
|
-
/** @public */
|
|
167
|
-
resolveGitIdentity: resolveGitHubGitIdentity,
|
|
168
|
-
/** @public */
|
|
169
|
-
launcher: githubRepoChangeUiLauncher,
|
|
170
|
-
};
|
|
171
89
|
}
|
package/src/process.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { createRepositoryChangeProcess } from "@leitwerk-dev/coding";
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
createPullRequestChangeProcess,
|
|
4
3
|
publicationObject as object,
|
|
5
4
|
type PublicationSource,
|
|
6
|
-
|
|
7
|
-
pullRequestPublicationCallbacks,
|
|
8
|
-
pullRequestPublicationSources,
|
|
5
|
+
pullRequestPublicationDefaults,
|
|
9
6
|
readPublicationState,
|
|
10
|
-
reconcilePullRequestSourceIssue,
|
|
11
|
-
resolvePullRequestGitIdentity,
|
|
12
7
|
} from "@leitwerk-dev/coding/repository-change-publication";
|
|
13
8
|
import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
|
|
14
9
|
import { githubExternal, githubIssueWatcherSource } from "@leitwerk-dev/github";
|
|
@@ -19,39 +14,27 @@ import {
|
|
|
19
14
|
isIssueOrigin,
|
|
20
15
|
} from "./params.js";
|
|
21
16
|
|
|
22
|
-
const processId = "github_repo_change_process";
|
|
23
|
-
const ids = {
|
|
24
|
-
deliver: "deliver_change",
|
|
25
|
-
feedback: "revise_from_pull_request_feedback",
|
|
26
|
-
ciRepair: "repair_github_checks",
|
|
27
|
-
operator: "ci_operator_action",
|
|
28
|
-
};
|
|
29
17
|
const remote = (state: RepositoryChangeState) => readPublicationState(state, "githubRepoChange");
|
|
30
18
|
|
|
31
|
-
const deliveryTools = [
|
|
32
|
-
"github_get_pull_request",
|
|
33
|
-
"github_add_pull_request_comment",
|
|
34
|
-
"github_resolve_git_identity",
|
|
35
|
-
"github_ensure_pull_request",
|
|
36
|
-
"github_add_issue_comment",
|
|
37
|
-
"github_add_pull_request_feedback_reaction",
|
|
38
|
-
"github_reply_to_pull_request_feedback",
|
|
39
|
-
"github_get_issue",
|
|
40
|
-
"github_ensure_label",
|
|
41
|
-
"github_update_issue",
|
|
42
|
-
] as const;
|
|
43
|
-
|
|
44
19
|
/** @public */
|
|
45
20
|
export function createGitHubRepoChangeProcess(
|
|
46
21
|
launcher: ReturnType<typeof createGitHubRepoChangeLauncher>,
|
|
47
22
|
docker: boolean,
|
|
48
23
|
) {
|
|
49
|
-
const sharedSources =
|
|
24
|
+
const sharedSources = pullRequestPublicationDefaults<GitHubRepoChangeParams>(
|
|
50
25
|
"github",
|
|
51
26
|
"GitHub",
|
|
52
27
|
githubExternal,
|
|
53
28
|
(params) => params.githubProfile,
|
|
54
29
|
(params) => (isIssueOrigin(params) ? params : undefined),
|
|
30
|
+
"name",
|
|
31
|
+
{
|
|
32
|
+
id: "repair_github_checks",
|
|
33
|
+
label: "GitHub checks",
|
|
34
|
+
tools: ["github_get_ci_diagnostics"],
|
|
35
|
+
prompt: (current) =>
|
|
36
|
+
`Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`,
|
|
37
|
+
},
|
|
55
38
|
);
|
|
56
39
|
const { requirePr } = sharedSources;
|
|
57
40
|
const failedPipeline = githubExternal.checks<GitHubRepoChangeParams, RepositoryChangeState>(
|
|
@@ -66,11 +49,8 @@ export function createGitHubRepoChangeProcess(
|
|
|
66
49
|
);
|
|
67
50
|
|
|
68
51
|
const sources: PublicationSource<GitHubRepoChangeParams>[] = [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
kind: "conflict",
|
|
72
|
-
label: "Rebase conflicting pull request",
|
|
73
|
-
source: githubExternal.pullRequestState(({ params, state }) => ({
|
|
52
|
+
sharedSources.conflict(
|
|
53
|
+
githubExternal.pullRequestState(({ params, state }) => ({
|
|
74
54
|
profile: params.githubProfile,
|
|
75
55
|
owner: params.owner,
|
|
76
56
|
repo: params.repo,
|
|
@@ -81,11 +61,7 @@ export function createGitHubRepoChangeProcess(
|
|
|
81
61
|
eventKinds: ["merge_conflict"],
|
|
82
62
|
pollInterval: "30s",
|
|
83
63
|
})),
|
|
84
|
-
|
|
85
|
-
kind: "conflict",
|
|
86
|
-
conflict: object(event).conflict as NonNullable<PublicationState["conflict"]>,
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
64
|
+
),
|
|
89
65
|
sharedSources.feedback,
|
|
90
66
|
{
|
|
91
67
|
id: "github_failure_repair",
|
|
@@ -112,66 +88,15 @@ export function createGitHubRepoChangeProcess(
|
|
|
112
88
|
...sharedSources.terminal,
|
|
113
89
|
sharedSources.cancelled,
|
|
114
90
|
];
|
|
115
|
-
|
|
116
|
-
namespace: "githubRepoChange",
|
|
117
|
-
label: "GitHub PR",
|
|
118
|
-
ids,
|
|
119
|
-
sources,
|
|
120
|
-
tools: {
|
|
121
|
-
delivery: deliveryTools,
|
|
122
|
-
feedback: ["github_get_pull_request", "github_list_pull_request_feedback"],
|
|
123
|
-
ci: ["github_get_ci_diagnostics"],
|
|
124
|
-
},
|
|
125
|
-
identity: (ctx) => resolvePullRequestGitIdentity(ctx, "github", ctx.params.githubProfile),
|
|
126
|
-
reconcileTerminal: reconcilePullRequestSourceIssue<GitHubRepoChangeParams>(
|
|
127
|
-
"github",
|
|
128
|
-
"name",
|
|
129
|
-
(params) => (isIssueOrigin(params) ? params : undefined),
|
|
130
|
-
),
|
|
131
|
-
...pullRequestPublicationCallbacks<GitHubRepoChangeParams>("github", "GitHub", (params) =>
|
|
132
|
-
isIssueOrigin(params) ? params : undefined,
|
|
133
|
-
),
|
|
134
|
-
commitMessage: (kind) =>
|
|
135
|
-
kind === "feedback" ? "fix: address GitHub review feedback" : "fix: repair GitHub checks",
|
|
136
|
-
prompt(kind, current) {
|
|
137
|
-
return kind === "feedback"
|
|
138
|
-
? `Address the unseen GitHub pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use GitHub tools to read the full feedback. Do not rely on an earlier plan or conversation. Make only justified repository changes. Call changes_ready if files need publishing, no_changes after an explicit diagnosis that no repository change is needed, or cannot_repair when operator action is required.`
|
|
139
|
-
: `Diagnose failed GitHub checks for request #${current.prNumber}, head ${current.headSha}. Use github_get_ci_diagnostics with pullRequestNumber and headSha to inspect failed check annotations and bounded Actions job logs before changing anything. Fix repository causes. Call changes_ready for repository changes, no_changes only after an explicit provider restart or a justified diagnosis that no repository change is needed, or cannot_repair when operator action is required.`;
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
const publication = publicationConfig.fragment;
|
|
143
|
-
publication.watcher({
|
|
144
|
-
id: "use_leitwerk",
|
|
145
|
-
label: "GitHub use-leitwerk issues",
|
|
146
|
-
description: "Launch a remote repository change for GitHub issues carrying the trigger label",
|
|
147
|
-
source: githubIssueWatcherSource,
|
|
148
|
-
preparationChecks: launcher.preparationChecks,
|
|
149
|
-
resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const definition = createRepositoryChangeProcess<GitHubRepoChangeParams>({
|
|
153
|
-
processId,
|
|
154
|
-
displayName: "GitHub Repo Change",
|
|
91
|
+
return createPullRequestChangeProcess("github", "GitHub", docker, {
|
|
155
92
|
paramsCodec: githubRepoChangeParamsCodec,
|
|
156
93
|
launcher: launcher.launcher,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
94
|
+
workflow: launcher.workflow,
|
|
95
|
+
publication: { ...sharedSources.adapter, sources },
|
|
96
|
+
watcher: {
|
|
97
|
+
source: githubIssueWatcherSource,
|
|
98
|
+
preparationChecks: launcher.preparationChecks,
|
|
99
|
+
resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,
|
|
163
100
|
},
|
|
164
|
-
repositoryCredentials: ({ params }) => [
|
|
165
|
-
{
|
|
166
|
-
projectKey: "repo",
|
|
167
|
-
kind: "git_ssh",
|
|
168
|
-
credentialRef: params.sshCredentialRef,
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
publication: publicationConfig,
|
|
172
101
|
});
|
|
173
|
-
|
|
174
|
-
definition.process.runtime = { ...definition.process.runtime, docker };
|
|
175
|
-
|
|
176
|
-
return definition.process;
|
|
177
102
|
}
|