@leitwerk-dev/forgejo-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 CHANGED
@@ -36,12 +36,16 @@ changes; mappings affect future launches.
36
36
 
37
37
  The UI starts without a source issue. Each replay generates a new work branch.
38
38
  Issue launches retain their external issue identity and `leitwerk/issue-N` branch.
39
- Plans and implementations require operator approval. Optional review,
40
- simplification, and imported-plan routes share the coding process contracts.
39
+ The [shared workflow](../coding/README.md#streamlined-coordinated-changes) requires
40
+ plan approval, then simplifies and publishes automatically. UI launches can skip
41
+ plan approval or simplification; relaunch preserves both choices. Issue launches
42
+ read `leitwerk-skip-simplification` after implementation, never use labels to bypass
43
+ plan approval, and retain completed routing decisions on recovery.
41
44
 
42
45
  ## Delivery and recovery
43
46
 
44
- The automatic `deliver_change` turn commits with the server-pinned Forgejo Git
47
+ Unchanged work completes without a PR; source issues stay open, lose the trigger,
48
+ and receive a comment. Otherwise `deliver_change` commits with the server-pinned Forgejo Git
45
49
  identity, pushes a feature branch, and creates or reconciles one pull request.
46
50
  It records delivery progress, feedback acknowledgements/replies, and provider
47
51
  write receipts. External writes are durable and safe to retry.
@@ -85,20 +89,7 @@ At operator action, **Retry repair** retains the pending evidence. **Resume wait
85
89
  dismisses the pending feedback and adjustment, retaining accepted feedback cursors
86
90
  and remote delivery state while waiting for new evidence.
87
91
 
88
- ## Integration tests
89
-
90
- The composed workflow tests copy a pristine Git seed into independent repositories
91
- and own their storage per scenario. They retain real Git, HTTP actions and worker
92
- IPC without repeating repository initialization. Failures report process and turn
93
- state before cleanup.
94
-
95
- ## Restart verification
96
-
97
- The provider sandbox's file-backed restart fixtures retain legacy issue/UI params,
98
- Forgejo-only project metadata, completed write receipts and waiting subscriptions.
99
- They reopen feedback, CI, conflict, operator and terminal deliveries, compare project,
100
- turn and session identities, and verify that changed profile mappings do not rebind
101
- existing work. A remote merge while the server is stopped completes after rearming.
92
+ A remote merge while the server is stopped completes after rearming.
102
93
  Lost PR responses and publication retries reconcile one PR without duplicate comments.
103
94
 
104
95
  ## API support
package/dist/index.d.ts CHANGED
@@ -12,9 +12,9 @@ export declare function createForgejoRepoChange(options: {
12
12
  /** @internal */
13
13
  launcher: {
14
14
  /** @internal */
15
- configure: (value: import("./launcher.js").LauncherDependencies | null) => void;
15
+ configure(value: import("./launcher.js").LauncherDependencies | null): void;
16
16
  /** @internal */
17
- preparationChecks: (_input: unknown, { params }: import("@leitwerk-dev/process-sdk").ProcessLaunchConfig<import("./params.js").ForgejoRepoChangeParams>) => readonly import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<import("./params.js").ForgejoRepoChangeParams>[];
17
+ preparationChecks: (_input: unknown, { params }: import("@leitwerk-dev/process-sdk").ProcessLaunchConfig<import("./params.js").ForgejoRepoChangeParams>) => import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<import("./params.js").ForgejoRepoChangeParams>[];
18
18
  /** @internal */
19
19
  resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
20
20
  /** @internal */
@@ -33,6 +33,8 @@ export declare function createForgejoRepoChange(options: {
33
33
  labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
34
34
  }): Promise<import("@leitwerk-dev/process-sdk").ProcessLaunchConfig<import("./params.js").ForgejoRepoChangeParams>>;
35
35
  };
36
+ /** @internal */
37
+ workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<import("./params.js").ForgejoRepoChangeParams>;
36
38
  };
37
39
  };
38
40
  export type { ForgejoRepoChangeParams } from "./params.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAIzE,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAevF,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAChD,cAAc;IACd,MAAM,EAAE,OAAO,CAAC;CAChB;IAyBC,cAAc;;IAEd,cAAc;;IAEd,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;EAGjB;AAED,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,gBAAgB;AAChB,QAAA,MAAmB,gBAAgB,yBAA8C,CAAC;AAClF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAIzE,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAevF,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAChD,cAAc;IACd,MAAM,EAAE,OAAO,CAAC;CAChB;IAyBC,cAAc;;IAEd,cAAc;;IAEd,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjB;AAED,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,gBAAgB;AAChB,QAAA,MAAmB,gBAAgB,yBAA8C,CAAC;AAClF,eAAe,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import { woodpeckerIntegration } from "@leitwerk-dev/woodpecker";
5
5
 
6
6
  // src/launcher.ts
7
7
  import {
8
- createRepositoryChangeUiLauncher,
9
- repositoryVisibilityCheck
8
+ createRepositoryChangeLauncher,
9
+ repositoryIssueChangeLaunchConfig
10
10
  } from "@leitwerk-dev/coding/repository-change-launch";
11
11
  import { createGitSshPreparationCheck } from "@leitwerk-dev/git-ssh";
12
12
 
@@ -62,145 +62,78 @@ function forgejoRepoChangeParams(repository, input) {
62
62
  doneLabel: null
63
63
  };
64
64
  }
65
- function forgejoRepoChangeLaunchConfig(params, title, gitIdentity) {
65
+ function forgejoRepoChangeLaunchConfig(params, title, gitIdentity, repository) {
66
66
  const { owner, repo, forgejoProfile: profile, woodpeckerProfile } = params;
67
67
  const issue = isIssueOrigin(params);
68
- return {
69
- processId: "forgejo_repo_change_process",
68
+ return repositoryIssueChangeLaunchConfig(
69
+ "forgejo",
70
70
  params,
71
71
  title,
72
- startTurnId: "generate_plan",
73
- ...issue ? {
74
- externalId: `forgejo:${owner}/${repo}#${params.issueNumber}`,
75
- externalUrl: params.issueUrl
76
- } : {},
77
- projects: [
78
- {
79
- key: "repo",
80
- repoLocator: params.repoLocator,
81
- baseBranch: params.baseBranch,
82
- workBranch: params.workBranch,
83
- ...issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {},
84
- metadata: {
85
- forgejo: { owner, repo, profile, ...issue ? { issueNumber: params.issueNumber } : {} },
86
- woodpecker: { owner, repo, profile: woodpeckerProfile },
87
- "leitwerk.gitIdentity": gitIdentity
88
- }
89
- }
90
- ]
91
- };
72
+ `${owner}/${repo}`,
73
+ {
74
+ forgejo: { owner, repo, profile, ...issue ? { issueNumber: params.issueNumber } : {} },
75
+ woodpecker: { owner, repo, profile: woodpeckerProfile },
76
+ "leitwerk.gitIdentity": gitIdentity
77
+ },
78
+ repository
79
+ );
92
80
  }
93
81
  function createForgejoRepoChangeLauncher() {
94
- let dependencies = null;
95
- function configureForgejoRepoChangeLauncher(value) {
96
- dependencies = value;
97
- }
98
- function requireDependencies() {
99
- if (!dependencies) throw new Error("Forgejo repository launcher is not configured");
100
- return dependencies;
101
- }
102
- function forgejoRepositoryPreparationChecks(_input, { params }) {
103
- return [
104
- repositoryVisibilityCheck(
105
- "Forgejo",
106
- async () => (await repositories(params.forgejoProfile)).some(
107
- (candidate) => candidate.full_name === `${params.owner}/${params.repo}`
108
- )
109
- ),
110
- createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
111
- createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh)
112
- ];
113
- }
114
- function resolveProfiles(profile) {
115
- const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
116
- if (!forgejo.profiles().includes(profile)) throw new Error("Forgejo profile is not available");
117
- const binding = resolveProfileBinding(profileBindings, profile);
118
- try {
119
- woodpecker.client(binding.woodpeckerProfile);
120
- } catch {
121
- throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
122
- }
123
- if (!gitSsh.profiles().includes(binding.sshCredentialRef))
124
- throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
125
- return binding;
126
- }
127
- async function resolveForgejoGitIdentity(profile) {
128
- if (!profile) throw new Error("A Forgejo profile is required to resolve Git identity");
129
- return requireDependencies().forgejo.client(profile).resolveGitIdentity(profile);
130
- }
131
- async function repositories(profile) {
132
- if (!profile) return [];
133
- const { forgejo } = requireDependencies();
134
- if (!forgejo.profiles().includes(profile)) return [];
135
- return forgejo.client(profile).listRepositories();
136
- }
137
- const forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
82
+ return createRepositoryChangeLauncher({
138
83
  id: forgejoRepoChangeUiLauncherId,
139
84
  provider: "Forgejo",
140
85
  providerId: "forgejo",
141
- assertConfigured: requireDependencies,
142
- profiles: () => requireDependencies().forgejo.profiles(),
143
- repositories,
144
- resolveProfiles,
145
- resolveGitIdentity: resolveForgejoGitIdentity,
86
+ integration: (deps) => deps.forgejo,
87
+ profile: (params) => params.forgejoProfile,
146
88
  params: forgejoRepoChangeParams,
147
89
  launchConfig: forgejoRepoChangeLaunchConfig,
148
- preparationChecks: forgejoRepositoryPreparationChecks
90
+ resolveProfiles(profile, { woodpecker, gitSsh, profileBindings = {} }) {
91
+ const binding = resolveProfileBinding(profileBindings, profile);
92
+ try {
93
+ woodpecker.client(binding.woodpeckerProfile);
94
+ } catch {
95
+ throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
96
+ }
97
+ if (!gitSsh.profiles().includes(binding.sshCredentialRef))
98
+ throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
99
+ return binding;
100
+ },
101
+ preparationChecks: (params, dependencies) => [
102
+ createGitSshPreparationCheck("write", params, () => dependencies().gitSsh)
103
+ ]
149
104
  });
150
- return {
151
- /** @internal */
152
- configure: configureForgejoRepoChangeLauncher,
153
- /** @internal */
154
- preparationChecks: forgejoRepositoryPreparationChecks,
155
- /** @internal */
156
- resolveProfiles,
157
- /** @internal */
158
- resolveGitIdentity: resolveForgejoGitIdentity,
159
- /** @internal */
160
- launcher: forgejoRepoChangeUiLauncher
161
- };
162
105
  }
163
106
 
164
107
  // src/process.ts
165
- import { createRepositoryChangeProcess } from "@leitwerk-dev/coding";
166
108
  import {
167
- createRepositoryChangePublication,
109
+ createPullRequestChangeProcess,
168
110
  publicationObject as object,
169
- pullRequestPublicationCallbacks,
170
- pullRequestPublicationSources,
171
- readPublicationState,
172
- reconcilePullRequestSourceIssue,
173
- resolvePullRequestGitIdentity
111
+ pullRequestPublicationDefaults,
112
+ readPublicationState
174
113
  } from "@leitwerk-dev/coding/repository-change-publication";
175
114
  import { forgejoExternal, forgejoIssueWatcherSource } from "@leitwerk-dev/forgejo";
176
115
  import { woodpeckerExternal } from "@leitwerk-dev/woodpecker";
177
- var processId = "forgejo_repo_change_process";
178
- var ids = {
179
- deliver: "deliver_change",
180
- feedback: "revise_from_pull_request_feedback",
181
- ciRepair: "repair_woodpecker_pipeline",
182
- operator: "ci_operator_action"
183
- };
184
116
  var remote = (state) => readPublicationState(state, "forgejoRepoChange");
185
- var deliveryTools = [
186
- "forgejo_get_pull_request",
187
- "forgejo_add_pull_request_comment",
188
- "forgejo_resolve_git_identity",
189
- "forgejo_ensure_pull_request",
190
- "forgejo_add_issue_comment",
191
- "forgejo_add_pull_request_feedback_reaction",
192
- "forgejo_reply_to_pull_request_feedback",
193
- "forgejo_get_issue",
194
- "forgejo_ensure_label",
195
- "forgejo_update_issue"
196
- ];
197
117
  function createForgejoRepoChangeProcess(launcher, docker) {
198
- const sharedSources = pullRequestPublicationSources(
118
+ const sharedSources = pullRequestPublicationDefaults(
199
119
  "forgejo",
200
120
  "Forgejo",
201
121
  forgejoExternal,
202
122
  (params) => params.forgejoProfile,
203
- (params) => isIssueOrigin(params) ? params : void 0
123
+ (params) => isIssueOrigin(params) ? params : void 0,
124
+ "id",
125
+ {
126
+ id: "repair_woodpecker_pipeline",
127
+ label: "Woodpecker pipeline",
128
+ tools: [
129
+ "woodpecker_lookup_repository",
130
+ "woodpecker_list_pipelines",
131
+ "woodpecker_get_pipeline",
132
+ "woodpecker_get_step_logs",
133
+ "woodpecker_restart_pipeline"
134
+ ],
135
+ prompt: (current) => `Diagnose Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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.`
136
+ }
204
137
  );
205
138
  const { requirePr } = sharedSources;
206
139
  const failedPipeline = woodpeckerExternal.pipeline(({ params, state }) => {
@@ -217,11 +150,8 @@ function createForgejoRepoChangeProcess(launcher, docker) {
217
150
  };
218
151
  });
219
152
  const sources = [
220
- {
221
- id: "forgejo_merge_conflict",
222
- kind: "conflict",
223
- label: "Rebase conflicting pull request",
224
- source: forgejoExternal.pullRequestConflict(({ params, state }) => ({
153
+ sharedSources.conflict(
154
+ forgejoExternal.pullRequestConflict(({ params, state }) => ({
225
155
  profile: params.forgejoProfile,
226
156
  owner: params.owner,
227
157
  repo: params.repo,
@@ -229,12 +159,8 @@ function createForgejoRepoChangeProcess(launcher, docker) {
229
159
  headSha: requirePr(state).headSha,
230
160
  lastConflictKey: remote(state).lastConflictKey,
231
161
  pollInterval: "30s"
232
- })),
233
- read: ({ event }) => ({
234
- kind: "conflict",
235
- conflict: object(event).conflict
236
- })
237
- },
162
+ }))
163
+ ),
238
164
  sharedSources.feedback,
239
165
  {
240
166
  id: "woodpecker_failure_repair",
@@ -250,70 +176,17 @@ function createForgejoRepoChangeProcess(launcher, docker) {
250
176
  ...sharedSources.terminal,
251
177
  sharedSources.cancelled
252
178
  ];
253
- const publicationConfig = createRepositoryChangePublication({
254
- namespace: "forgejoRepoChange",
255
- label: "Forgejo PR",
256
- ids,
257
- sources,
258
- tools: {
259
- delivery: deliveryTools,
260
- feedback: ["forgejo_get_pull_request", "forgejo_list_pull_request_feedback"],
261
- ci: [
262
- "woodpecker_lookup_repository",
263
- "woodpecker_list_pipelines",
264
- "woodpecker_get_pipeline",
265
- "woodpecker_get_step_logs",
266
- "woodpecker_restart_pipeline"
267
- ]
268
- },
269
- identity: (ctx) => resolvePullRequestGitIdentity(ctx, "forgejo", ctx.params.forgejoProfile),
270
- reconcileTerminal: reconcilePullRequestSourceIssue(
271
- "forgejo",
272
- "id",
273
- (params) => isIssueOrigin(params) ? params : void 0
274
- ),
275
- ...pullRequestPublicationCallbacks(
276
- "forgejo",
277
- "Forgejo",
278
- (params) => isIssueOrigin(params) ? params : void 0
279
- ),
280
- commitMessage: (kind) => kind === "feedback" ? "fix: address Forgejo review feedback" : "fix: repair Woodpecker pipeline",
281
- prompt(kind, current) {
282
- return kind === "feedback" ? `Address the unseen Forgejo pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use Forgejo 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 Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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.`;
283
- }
284
- });
285
- const publication = publicationConfig.fragment;
286
- publication.watcher({
287
- id: "use_leitwerk",
288
- label: "Forgejo use-leitwerk issues",
289
- description: "Launch a remote repository change for Forgejo issues carrying the trigger label",
290
- source: forgejoIssueWatcherSource,
291
- preparationChecks: launcher.preparationChecks,
292
- resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig
293
- });
294
- const definition = createRepositoryChangeProcess({
295
- processId,
296
- displayName: "Forgejo Repo Change",
179
+ return createPullRequestChangeProcess("forgejo", "Forgejo", docker, {
297
180
  paramsCodec: forgejoRepoChangeParamsCodec,
298
181
  launcher: launcher.launcher,
299
- finalizeLabel: "Publish pull request",
300
- finalizeForm: {
301
- id: "forgejo_publish",
302
- title: "Publish pull request",
303
- fields: [],
304
- submitLabel: "Publish"
305
- },
306
- repositoryCredentials: ({ params }) => [
307
- {
308
- projectKey: "repo",
309
- kind: "git_ssh",
310
- credentialRef: params.sshCredentialRef
311
- }
312
- ],
313
- publication: publicationConfig
182
+ workflow: launcher.workflow,
183
+ publication: { ...sharedSources.adapter, sources },
184
+ watcher: {
185
+ source: forgejoIssueWatcherSource,
186
+ preparationChecks: launcher.preparationChecks,
187
+ resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig
188
+ }
314
189
  });
315
- definition.process.runtime = { ...definition.process.runtime, docker };
316
- return definition.process;
317
190
  }
318
191
 
319
192
  // src/index.ts
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 { forgejoIntegration } from \"@leitwerk-dev/forgejo\";\nimport { gitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { woodpeckerIntegration } from \"@leitwerk-dev/woodpecker\";\nimport { createForgejoRepoChangeLauncher } from \"./launcher.js\";\n\nexport { forgejoRepoChangeLaunchConfig, forgejoRepoChangeParams } from \"./launcher.js\";\n\nimport { createForgejoRepoChangeProcess } from \"./process.js\";\nimport { parseProfileBindings } from \"./profile-bindings.js\";\n\n/** @internal */\nconst manifest = {\n\t/** @internal */\n\tid: \"forgejo-repo-change\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n\t/** @internal */\n\trequires: [\"forgejo\", \"woodpecker\", \"coding\", \"git-ssh\"],\n} as const;\n\n/** Load exactly one variant per catalog. Only trusted composition code selects Docker. @public */\nexport function createForgejoRepoChange(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 = createForgejoRepoChangeLauncher();\n\tconst process = createForgejoRepoChangeProcess(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 forgejo = api.require(forgejoIntegration);\n\t\t\tconst gitSsh = api.require(gitSshIntegration);\n\t\t\tconst woodpecker = api.require(woodpeckerIntegration);\n\t\t\tif (Array.isArray(forgejo) || Array.isArray(gitSsh) || Array.isArray(woodpecker))\n\t\t\t\tthrow new Error(\"Repository delivery integrations must be singular\");\n\t\t\tlauncher.configure({\n\t\t\t\tforgejo,\n\t\t\t\tgitSsh,\n\t\t\t\twoodpecker,\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\treturn {\n\t\t/** @public */\n\t\textension,\n\t\t/** @public */\n\t\tprocess,\n\t\t/** @internal */\n\t\tlauncher,\n\t};\n}\n\nexport type { ForgejoRepoChangeParams } from \"./params.js\";\n\n/** @internal */\nconst { extension: defaultExtension } = createForgejoRepoChange({ docker: true });\nexport default defaultExtension;\n","import {\n\tcreateRepositoryChangeUiLauncher,\n\trepositoryVisibilityCheck,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\nimport type {\n\tForgejoGitIdentity,\n\tForgejoIntegration,\n\tForgejoRepository,\n} from \"@leitwerk-dev/forgejo\";\nimport { createGitSshPreparationCheck, type GitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { LaunchPreparationCheck, ProcessLaunchConfig } from \"@leitwerk-dev/process-sdk\";\nimport type { WoodpeckerIntegration } from \"@leitwerk-dev/woodpecker\";\nimport { type ForgejoRepoChangeParams, isIssueOrigin } from \"./params.js\";\nimport { type ProfileBindings, resolveProfileBinding } from \"./profile-bindings.js\";\n\n/** @internal */\nexport const forgejoRepoChangeUiLauncherId = \"forgejo_repo_change_process.ui_launcher\" as const;\n\n/** @internal */\nexport function forgejoRepoChangeParams(\n\trepository: ForgejoRepository,\n\tinput: {\n\t\t/** @internal */\n\t\tprofile: string;\n\t\t/** @internal */\n\t\twoodpeckerProfile: string;\n\t\t/** @internal */\n\t\tsshCredentialRef: string;\n\t\t/** @internal */\n\t\tprompt: string;\n\t\t/** @internal */\n\t\tworkBranch: string;\n\t},\n): ForgejoRepoChangeParams {\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\tforgejoProfile: input.profile,\n\t\twoodpeckerProfile: input.woodpeckerProfile,\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/** @internal */\nexport function forgejoRepoChangeLaunchConfig(\n\tparams: ForgejoRepoChangeParams,\n\ttitle: string,\n\tgitIdentity: ForgejoGitIdentity,\n): ProcessLaunchConfig<ForgejoRepoChangeParams> {\n\tconst { owner, repo, forgejoProfile: profile, woodpeckerProfile } = params;\n\tconst issue = isIssueOrigin(params);\n\treturn {\n\t\tprocessId: \"forgejo_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: `forgejo:${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\tforgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },\n\t\t\t\t\twoodpecker: { owner, repo, profile: woodpeckerProfile },\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/** @internal */\nexport interface LauncherDependencies {\n\t/** @internal */\n\tforgejo: ForgejoIntegration;\n\t/** @internal */\n\tgitSsh: GitSshIntegration;\n\t/** @internal */\n\twoodpecker: WoodpeckerIntegration;\n\t/** @internal */\n\tprofileBindings?: ProfileBindings;\n}\n\n/** @internal */\nexport function createForgejoRepoChangeLauncher() {\n\tlet dependencies: LauncherDependencies | null = null;\n\n\t/** @internal */\n\tfunction configureForgejoRepoChangeLauncher(value: LauncherDependencies | null): void {\n\t\tdependencies = value;\n\t}\n\n\tfunction requireDependencies(): LauncherDependencies {\n\t\tif (!dependencies) throw new Error(\"Forgejo repository launcher is not configured\");\n\t\treturn dependencies;\n\t}\n\n\t/** @internal */\n\tfunction forgejoRepositoryPreparationChecks(\n\t\t_input: unknown,\n\t\t{ params }: ProcessLaunchConfig<ForgejoRepoChangeParams>,\n\t): readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[] {\n\t\treturn [\n\t\t\trepositoryVisibilityCheck(\"Forgejo\", async () =>\n\t\t\t\t(await repositories(params.forgejoProfile)).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/** @internal */\n\tfunction resolveProfiles(profile: string) {\n\t\tconst { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();\n\t\tif (!forgejo.profiles().includes(profile)) throw new Error(\"Forgejo profile is not available\");\n\t\tconst binding = resolveProfileBinding(profileBindings, profile);\n\t\ttry {\n\t\t\twoodpecker.client(binding.woodpeckerProfile);\n\t\t} catch {\n\t\t\tthrow new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);\n\t\t}\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/** @internal */\n\tasync function resolveForgejoGitIdentity(profile: string): Promise<ForgejoGitIdentity> {\n\t\tif (!profile) throw new Error(\"A Forgejo profile is required to resolve Git identity\");\n\t\treturn requireDependencies().forgejo.client(profile).resolveGitIdentity(profile);\n\t}\n\n\tasync function repositories(profile: string): Promise<readonly ForgejoRepository[]> {\n\t\tif (!profile) return [];\n\t\tconst { forgejo } = requireDependencies();\n\t\tif (!forgejo.profiles().includes(profile)) return [];\n\t\treturn forgejo.client(profile).listRepositories();\n\t}\n\n\tconst forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({\n\t\tid: forgejoRepoChangeUiLauncherId,\n\t\tprovider: \"Forgejo\",\n\t\tproviderId: \"forgejo\",\n\t\tassertConfigured: requireDependencies,\n\t\tprofiles: () => requireDependencies().forgejo.profiles(),\n\t\trepositories,\n\t\tresolveProfiles,\n\t\tresolveGitIdentity: resolveForgejoGitIdentity,\n\t\tparams: forgejoRepoChangeParams,\n\t\tlaunchConfig: forgejoRepoChangeLaunchConfig,\n\t\tpreparationChecks: forgejoRepositoryPreparationChecks,\n\t});\n\n\treturn {\n\t\t/** @internal */\n\t\tconfigure: configureForgejoRepoChangeLauncher,\n\t\t/** @internal */\n\t\tpreparationChecks: forgejoRepositoryPreparationChecks,\n\t\t/** @internal */\n\t\tresolveProfiles,\n\t\t/** @internal */\n\t\tresolveGitIdentity: resolveForgejoGitIdentity,\n\t\t/** @internal */\n\t\tlauncher: forgejoRepoChangeUiLauncher,\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 ForgejoRepoChangeCommonParams {\n\t/** @internal */\n\tforgejoProfile: string;\n\t/** @internal */\n\twoodpeckerProfile: string;\n\t/** @internal */\n\tsshCredentialRef: string;\n\t/** @internal */\n\towner: string;\n\t/** @internal */\n\trepo: string;\n}\n\n/** @public */\nexport interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {}\n\n/** @public */\nexport interface ForgejoUiOriginParams extends RepositoryUiOriginParams {}\n\n/** @public */\nexport type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<\n\tForgejoRepoChangeCommonParams & (ForgejoIssueOriginParams | ForgejoUiOriginParams)\n>;\n\n/** @internal */\nexport function isIssueOrigin(\n\tparams: ForgejoRepoChangeParams,\n): params is ForgejoRepoChangeParams & ForgejoIssueOriginParams {\n\treturn params.origin === \"issue\";\n}\n\n/** @internal */\nexport const forgejoRepoChangeParamsCodec =\n\tcreateRepositoryChangeParamsCodec<ForgejoRepoChangeParams>({\n\t\tnormalize(value) {\n\t\t\treturn normalizeRepositoryIssueChangeParams(value, \"Forgejo Repo Change\", [\n\t\t\t\t\"forgejoProfile\",\n\t\t\t\t\"woodpeckerProfile\",\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. @internal */\nexport interface ProfileBinding {\n\t/** @internal */\n\twoodpeckerProfile: string;\n\t/** @internal */\n\tsshCredentialRef: string;\n}\n/** @internal */\nexport type ProfileBindings = Readonly<Record<string, Readonly<ProfileBinding>>>;\n\n/** @internal */\nexport function parseProfileBindings(raw: unknown): ProfileBindings {\n\treturn parseRepositoryProfileBindings(raw, \"forgejo-repo-change\", {\n\t\twoodpeckerProfile: \"woodpecker_profile\",\n\t\tsshCredentialRef: \"ssh_credential_ref\",\n\t});\n}\n/** @internal */\nexport function resolveProfileBinding(bindings: ProfileBindings, profile: string): ProfileBinding {\n\treturn Object.hasOwn(bindings, profile)\n\t\t? { ...bindings[profile] }\n\t\t: { woodpeckerProfile: profile, 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 { forgejoExternal, forgejoIssueWatcherSource } from \"@leitwerk-dev/forgejo\";\nimport { woodpeckerExternal } from \"@leitwerk-dev/woodpecker\";\nimport type { createForgejoRepoChangeLauncher } from \"./launcher.js\";\nimport {\n\ttype ForgejoRepoChangeParams,\n\tforgejoRepoChangeParamsCodec,\n\tisIssueOrigin,\n} from \"./params.js\";\n\nconst processId = \"forgejo_repo_change_process\";\nconst ids = {\n\tdeliver: \"deliver_change\",\n\tfeedback: \"revise_from_pull_request_feedback\",\n\tciRepair: \"repair_woodpecker_pipeline\",\n\toperator: \"ci_operator_action\",\n};\nconst remote = (state: RepositoryChangeState) => readPublicationState(state, \"forgejoRepoChange\");\n\nconst deliveryTools = [\n\t\"forgejo_get_pull_request\",\n\t\"forgejo_add_pull_request_comment\",\n\t\"forgejo_resolve_git_identity\",\n\t\"forgejo_ensure_pull_request\",\n\t\"forgejo_add_issue_comment\",\n\t\"forgejo_add_pull_request_feedback_reaction\",\n\t\"forgejo_reply_to_pull_request_feedback\",\n\t\"forgejo_get_issue\",\n\t\"forgejo_ensure_label\",\n\t\"forgejo_update_issue\",\n] as const;\n\n/** @internal */\nexport function createForgejoRepoChangeProcess(\n\tlauncher: ReturnType<typeof createForgejoRepoChangeLauncher>,\n\tdocker: boolean,\n) {\n\tconst sharedSources = pullRequestPublicationSources<ForgejoRepoChangeParams>(\n\t\t\"forgejo\",\n\t\t\"Forgejo\",\n\t\tforgejoExternal,\n\t\t(params) => params.forgejoProfile,\n\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t);\n\tconst { requirePr } = sharedSources;\n\tconst failedPipeline = woodpeckerExternal.pipeline<\n\t\tForgejoRepoChangeParams,\n\t\tRepositoryChangeState\n\t>(({ params, state }) => {\n\t\tconst current = requirePr(state);\n\t\treturn {\n\t\t\tprofile: params.woodpeckerProfile,\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tbranch: params.workBranch,\n\t\t\theadSha: current.headSha,\n\t\t\tafterPipelineNumber: current.pipeline?.number ?? 0,\n\t\t\tstatuses: [\"failure\", \"error\", \"killed\", \"canceled\", \"cancelled\", \"declined\", \"blocked\"],\n\t\t\tpollInterval: \"30s\",\n\t\t};\n\t});\n\n\tconst sources: PublicationSource<ForgejoRepoChangeParams>[] = [\n\t\t{\n\t\t\tid: \"forgejo_merge_conflict\",\n\t\t\tkind: \"conflict\",\n\t\t\tlabel: \"Rebase conflicting pull request\",\n\t\t\tsource: forgejoExternal.pullRequestConflict(({ params, state }) => ({\n\t\t\t\tprofile: params.forgejoProfile,\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\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: \"woodpecker_failure_repair\",\n\t\t\toperatorId: \"woodpecker_failure_operator\",\n\t\t\tkind: \"failure\",\n\t\t\tlabel: \"Repair failed Woodpecker pipeline\",\n\t\t\tsource: failedPipeline,\n\t\t\tread: ({ event }) => ({\n\t\t\t\tkind: \"failure\",\n\t\t\t\tpipeline: object(event).pipeline as NonNullable<PublicationState[\"pipeline\"]>,\n\t\t\t}),\n\t\t},\n\t\t...sharedSources.terminal,\n\t\tsharedSources.cancelled,\n\t];\n\tconst publicationConfig = createRepositoryChangePublication<ForgejoRepoChangeParams>({\n\t\tnamespace: \"forgejoRepoChange\",\n\t\tlabel: \"Forgejo PR\",\n\t\tids,\n\t\tsources,\n\t\ttools: {\n\t\t\tdelivery: deliveryTools,\n\t\t\tfeedback: [\"forgejo_get_pull_request\", \"forgejo_list_pull_request_feedback\"],\n\t\t\tci: [\n\t\t\t\t\"woodpecker_lookup_repository\",\n\t\t\t\t\"woodpecker_list_pipelines\",\n\t\t\t\t\"woodpecker_get_pipeline\",\n\t\t\t\t\"woodpecker_get_step_logs\",\n\t\t\t\t\"woodpecker_restart_pipeline\",\n\t\t\t],\n\t\t},\n\t\tidentity: (ctx) => resolvePullRequestGitIdentity(ctx, \"forgejo\", ctx.params.forgejoProfile),\n\t\treconcileTerminal: reconcilePullRequestSourceIssue<ForgejoRepoChangeParams>(\n\t\t\t\"forgejo\",\n\t\t\t\"id\",\n\t\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t\t),\n\t\t...pullRequestPublicationCallbacks<ForgejoRepoChangeParams>(\"forgejo\", \"Forgejo\", (params) =>\n\t\t\tisIssueOrigin(params) ? params : undefined,\n\t\t),\n\t\tcommitMessage: (kind) =>\n\t\t\tkind === \"feedback\"\n\t\t\t\t? \"fix: address Forgejo review feedback\"\n\t\t\t\t: \"fix: repair Woodpecker pipeline\",\n\t\tprompt(kind, current) {\n\t\t\treturn kind === \"feedback\"\n\t\t\t\t? `Address the unseen Forgejo pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use Forgejo 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 Woodpecker pipeline #${current.pipeline?.number ?? \"unknown\"} (${current.pipeline?.status ?? \"unknown\"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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: \"Forgejo use-leitwerk issues\",\n\t\tdescription: \"Launch a remote repository change for Forgejo issues carrying the trigger label\",\n\t\tsource: forgejoIssueWatcherSource,\n\t\tpreparationChecks: launcher.preparationChecks,\n\t\tresolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,\n\t});\n\n\tconst definition = createRepositoryChangeProcess<ForgejoRepoChangeParams>({\n\t\tprocessId,\n\t\tdisplayName: \"Forgejo Repo Change\",\n\t\tparamsCodec: forgejoRepoChangeParamsCodec,\n\t\tlauncher: launcher.launcher,\n\t\tfinalizeLabel: \"Publish pull request\",\n\t\tfinalizeForm: {\n\t\t\tid: \"forgejo_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,0BAA0B;AACnC,SAAS,yBAAyB;AAElC,SAAS,6BAA6B;;;ACHtC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAMP,SAAS,oCAA4D;;;ACTrE;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AA4BA,SAAS,cACf,QAC+D;AAC/D,SAAO,OAAO,WAAW;AAC1B;AAGO,IAAM,+BACZ,kCAA2D;AAAA,EAC1D,UAAU,OAAO;AAChB,WAAO,qCAAqC,OAAO,uBAAuB;AAAA,MACzE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF;AACD,CAAC;;;ACpDF,SAAS,sCAAsC;AAaxC,SAAS,qBAAqB,KAA+B;AACnE,SAAO,+BAA+B,KAAK,uBAAuB;AAAA,IACjE,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,EACnB,CAAC;AACF;AAEO,SAAS,sBAAsB,UAA2B,SAAiC;AACjG,SAAO,OAAO,OAAO,UAAU,OAAO,IACnC,EAAE,GAAG,SAAS,OAAO,EAAE,IACvB,EAAE,mBAAmB,SAAS,kBAAkB,QAAQ;AAC5D;;;AFRO,IAAM,gCAAgC;AAGtC,SAAS,wBACf,YACA,OAY0B;AAC1B,SAAO;AAAA,IACN,aAAa,WAAW;AAAA,IACxB,YAAY,WAAW;AAAA,IACvB,YAAY,MAAM;AAAA,IAClB,QAAQ,MAAM;AAAA,IACd,gBAAgB,MAAM;AAAA,IACtB,mBAAmB,MAAM;AAAA,IACzB,kBAAkB,MAAM;AAAA,IACxB,OAAO,WAAW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D;AAGO,SAAS,wBAAwB,SAGrC;AACF,MAAI,OAAO,QAAQ,WAAW,UAAW,OAAM,IAAI,MAAM,0BAA0B;AACnF,QAAM,WAAW,gCAAgC;AACjD,QAAM,UAAU,+BAA+B,UAAU,QAAQ,MAAM;AACvE,QAAM,YAAqC;AAAA,IAC1C;AAAA,IACA,aAAa,KAAK;AACjB,UAAI,gBAAgB,OAAO;AAAA,IAC5B;AAAA,IACA,YAAY,KAAK,QAAQ;AACxB,YAAM,UAAU,IAAI,QAAQ,kBAAkB;AAC9C,YAAM,SAAS,IAAI,QAAQ,iBAAiB;AAC5C,YAAM,aAAa,IAAI,QAAQ,qBAAqB;AACpD,UAAI,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,UAAU;AAC9E,cAAM,IAAI,MAAM,mDAAmD;AACpE,eAAS,UAAU;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,iBAAiB,qBAAqB,MAAM;AAAA,MAC7C,CAAC;AACD,UAAI,OAAO,MAAM,SAAS,UAAU,IAAI,CAAC;AAAA,IAC1C;AAAA,EACD;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EACD;AACD;AAKA,IAAM,EAAE,WAAW,iBAAiB,IAAI,wBAAwB,EAAE,QAAQ,KAAK,CAAC;AAChF,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/launcher.ts","../src/params.ts","../src/profile-bindings.ts","../src/process.ts"],"sourcesContent":["import { forgejoIntegration } from \"@leitwerk-dev/forgejo\";\nimport { gitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { woodpeckerIntegration } from \"@leitwerk-dev/woodpecker\";\nimport { createForgejoRepoChangeLauncher } from \"./launcher.js\";\n\nexport { forgejoRepoChangeLaunchConfig, forgejoRepoChangeParams } from \"./launcher.js\";\n\nimport { createForgejoRepoChangeProcess } from \"./process.js\";\nimport { parseProfileBindings } from \"./profile-bindings.js\";\n\n/** @internal */\nconst manifest = {\n\t/** @internal */\n\tid: \"forgejo-repo-change\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n\t/** @internal */\n\trequires: [\"forgejo\", \"woodpecker\", \"coding\", \"git-ssh\"],\n} as const;\n\n/** Load exactly one variant per catalog. Only trusted composition code selects Docker. @public */\nexport function createForgejoRepoChange(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 = createForgejoRepoChangeLauncher();\n\tconst process = createForgejoRepoChangeProcess(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 forgejo = api.require(forgejoIntegration);\n\t\t\tconst gitSsh = api.require(gitSshIntegration);\n\t\t\tconst woodpecker = api.require(woodpeckerIntegration);\n\t\t\tif (Array.isArray(forgejo) || Array.isArray(gitSsh) || Array.isArray(woodpecker))\n\t\t\t\tthrow new Error(\"Repository delivery integrations must be singular\");\n\t\t\tlauncher.configure({\n\t\t\t\tforgejo,\n\t\t\t\tgitSsh,\n\t\t\t\twoodpecker,\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\treturn {\n\t\t/** @public */\n\t\textension,\n\t\t/** @public */\n\t\tprocess,\n\t\t/** @internal */\n\t\tlauncher,\n\t};\n}\n\nexport type { ForgejoRepoChangeParams } from \"./params.js\";\n\n/** @internal */\nconst { extension: defaultExtension } = createForgejoRepoChange({ docker: true });\nexport default defaultExtension;\n","import {\n\tcreateRepositoryChangeLauncher,\n\ttype PullRequestChangeLaunchInput,\n\trepositoryIssueChangeLaunchConfig,\n} from \"@leitwerk-dev/coding/repository-change-launch\";\nimport type {\n\tForgejoGitIdentity,\n\tForgejoIntegration,\n\tForgejoRepository,\n} from \"@leitwerk-dev/forgejo\";\nimport { createGitSshPreparationCheck, type GitSshIntegration } from \"@leitwerk-dev/git-ssh\";\nimport type { ProcessLaunchConfig } from \"@leitwerk-dev/process-sdk\";\nimport type { WoodpeckerIntegration } from \"@leitwerk-dev/woodpecker\";\nimport { type ForgejoRepoChangeParams, isIssueOrigin } from \"./params.js\";\nimport { type ProfileBindings, resolveProfileBinding } from \"./profile-bindings.js\";\n\n/** @internal */\nexport const forgejoRepoChangeUiLauncherId = \"forgejo_repo_change_process.ui_launcher\" as const;\n\n/** @internal */\nexport function forgejoRepoChangeParams(\n\trepository: ForgejoRepository,\n\tinput: PullRequestChangeLaunchInput & {\n\t\t/** @internal */\n\t\twoodpeckerProfile: string;\n\t},\n): ForgejoRepoChangeParams {\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\tforgejoProfile: input.profile,\n\t\twoodpeckerProfile: input.woodpeckerProfile,\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/** @internal */\nexport function forgejoRepoChangeLaunchConfig(\n\tparams: ForgejoRepoChangeParams,\n\ttitle: string,\n\tgitIdentity: ForgejoGitIdentity,\n\trepository?: ForgejoRepository,\n): ProcessLaunchConfig<ForgejoRepoChangeParams> {\n\tconst { owner, repo, forgejoProfile: profile, woodpeckerProfile } = params;\n\tconst issue = isIssueOrigin(params);\n\treturn repositoryIssueChangeLaunchConfig(\n\t\t\"forgejo\",\n\t\tparams,\n\t\ttitle,\n\t\t`${owner}/${repo}`,\n\t\t{\n\t\t\tforgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },\n\t\t\twoodpecker: { owner, repo, profile: woodpeckerProfile },\n\t\t\t\"leitwerk.gitIdentity\": gitIdentity,\n\t\t},\n\t\trepository,\n\t);\n}\n\n/** @internal */\nexport interface LauncherDependencies {\n\t/** @internal */\n\tforgejo: ForgejoIntegration;\n\t/** @internal */\n\tgitSsh: GitSshIntegration;\n\t/** @internal */\n\twoodpecker: WoodpeckerIntegration;\n\t/** @internal */\n\tprofileBindings?: ProfileBindings;\n}\n\n/** @internal */\nexport function createForgejoRepoChangeLauncher() {\n\treturn createRepositoryChangeLauncher({\n\t\tid: forgejoRepoChangeUiLauncherId,\n\t\tprovider: \"Forgejo\",\n\t\tproviderId: \"forgejo\",\n\t\tintegration: (deps: LauncherDependencies) => deps.forgejo,\n\t\tprofile: (params: ForgejoRepoChangeParams) => params.forgejoProfile,\n\t\tparams: forgejoRepoChangeParams,\n\t\tlaunchConfig: forgejoRepoChangeLaunchConfig,\n\t\tresolveProfiles(profile, { woodpecker, gitSsh, profileBindings = {} }) {\n\t\t\tconst binding = resolveProfileBinding(profileBindings, profile);\n\t\t\ttry {\n\t\t\t\twoodpecker.client(binding.woodpeckerProfile);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);\n\t\t\t}\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 ForgejoRepoChangeCommonParams {\n\t/** @internal */\n\tforgejoProfile: string;\n\t/** @internal */\n\twoodpeckerProfile: string;\n\t/** @internal */\n\tsshCredentialRef: string;\n\t/** @internal */\n\towner: string;\n\t/** @internal */\n\trepo: string;\n}\n\n/** @public */\nexport interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {}\n\n/** @public */\nexport interface ForgejoUiOriginParams extends RepositoryUiOriginParams {}\n\n/** @public */\nexport type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<\n\tForgejoRepoChangeCommonParams & (ForgejoIssueOriginParams | ForgejoUiOriginParams)\n>;\n\n/** @internal */\nexport function isIssueOrigin(\n\tparams: ForgejoRepoChangeParams,\n): params is ForgejoRepoChangeParams & ForgejoIssueOriginParams {\n\treturn params.origin === \"issue\";\n}\n\n/** @internal */\nexport const forgejoRepoChangeParamsCodec =\n\tcreateRepositoryChangeParamsCodec<ForgejoRepoChangeParams>({\n\t\tnormalize(value) {\n\t\t\treturn normalizeRepositoryIssueChangeParams(value, \"Forgejo Repo Change\", [\n\t\t\t\t\"forgejoProfile\",\n\t\t\t\t\"woodpeckerProfile\",\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. @internal */\nexport interface ProfileBinding {\n\t/** @internal */\n\twoodpeckerProfile: string;\n\t/** @internal */\n\tsshCredentialRef: string;\n}\n/** @internal */\nexport type ProfileBindings = Readonly<Record<string, Readonly<ProfileBinding>>>;\n\n/** @internal */\nexport function parseProfileBindings(raw: unknown): ProfileBindings {\n\treturn parseRepositoryProfileBindings(raw, \"forgejo-repo-change\", {\n\t\twoodpeckerProfile: \"woodpecker_profile\",\n\t\tsshCredentialRef: \"ssh_credential_ref\",\n\t});\n}\n/** @internal */\nexport function resolveProfileBinding(bindings: ProfileBindings, profile: string): ProfileBinding {\n\treturn Object.hasOwn(bindings, profile)\n\t\t? { ...bindings[profile] }\n\t\t: { woodpeckerProfile: profile, sshCredentialRef: profile };\n}\n","import {\n\tcreatePullRequestChangeProcess,\n\tpublicationObject as object,\n\ttype PublicationSource,\n\ttype PublicationState,\n\tpullRequestPublicationDefaults,\n\treadPublicationState,\n} from \"@leitwerk-dev/coding/repository-change-publication\";\nimport type { RepositoryChangeState } from \"@leitwerk-dev/coding/repository-change-state\";\nimport { forgejoExternal, forgejoIssueWatcherSource } from \"@leitwerk-dev/forgejo\";\nimport { woodpeckerExternal } from \"@leitwerk-dev/woodpecker\";\nimport type { createForgejoRepoChangeLauncher } from \"./launcher.js\";\nimport {\n\ttype ForgejoRepoChangeParams,\n\tforgejoRepoChangeParamsCodec,\n\tisIssueOrigin,\n} from \"./params.js\";\n\nconst remote = (state: RepositoryChangeState) => readPublicationState(state, \"forgejoRepoChange\");\n\n/** @internal */\nexport function createForgejoRepoChangeProcess(\n\tlauncher: ReturnType<typeof createForgejoRepoChangeLauncher>,\n\tdocker: boolean,\n) {\n\tconst sharedSources = pullRequestPublicationDefaults<ForgejoRepoChangeParams>(\n\t\t\"forgejo\",\n\t\t\"Forgejo\",\n\t\tforgejoExternal,\n\t\t(params) => params.forgejoProfile,\n\t\t(params) => (isIssueOrigin(params) ? params : undefined),\n\t\t\"id\",\n\t\t{\n\t\t\tid: \"repair_woodpecker_pipeline\",\n\t\t\tlabel: \"Woodpecker pipeline\",\n\t\t\ttools: [\n\t\t\t\t\"woodpecker_lookup_repository\",\n\t\t\t\t\"woodpecker_list_pipelines\",\n\t\t\t\t\"woodpecker_get_pipeline\",\n\t\t\t\t\"woodpecker_get_step_logs\",\n\t\t\t\t\"woodpecker_restart_pipeline\",\n\t\t\t],\n\t\t\tprompt: (current) =>\n\t\t\t\t`Diagnose Woodpecker pipeline #${current.pipeline?.number ?? \"unknown\"} (${current.pipeline?.status ?? \"unknown\"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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 = woodpeckerExternal.pipeline<\n\t\tForgejoRepoChangeParams,\n\t\tRepositoryChangeState\n\t>(({ params, state }) => {\n\t\tconst current = requirePr(state);\n\t\treturn {\n\t\t\tprofile: params.woodpeckerProfile,\n\t\t\towner: params.owner,\n\t\t\trepo: params.repo,\n\t\t\tbranch: params.workBranch,\n\t\t\theadSha: current.headSha,\n\t\t\tafterPipelineNumber: current.pipeline?.number ?? 0,\n\t\t\tstatuses: [\"failure\", \"error\", \"killed\", \"canceled\", \"cancelled\", \"declined\", \"blocked\"],\n\t\t\tpollInterval: \"30s\",\n\t\t};\n\t});\n\n\tconst sources: PublicationSource<ForgejoRepoChangeParams>[] = [\n\t\tsharedSources.conflict(\n\t\t\tforgejoExternal.pullRequestConflict(({ params, state }) => ({\n\t\t\t\tprofile: params.forgejoProfile,\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\tpollInterval: \"30s\",\n\t\t\t})),\n\t\t),\n\t\tsharedSources.feedback,\n\t\t{\n\t\t\tid: \"woodpecker_failure_repair\",\n\t\t\toperatorId: \"woodpecker_failure_operator\",\n\t\t\tkind: \"failure\",\n\t\t\tlabel: \"Repair failed Woodpecker pipeline\",\n\t\t\tsource: failedPipeline,\n\t\t\tread: ({ event }) => ({\n\t\t\t\tkind: \"failure\",\n\t\t\t\tpipeline: object(event).pipeline as NonNullable<PublicationState[\"pipeline\"]>,\n\t\t\t}),\n\t\t},\n\t\t...sharedSources.terminal,\n\t\tsharedSources.cancelled,\n\t];\n\treturn createPullRequestChangeProcess(\"forgejo\", \"Forgejo\", docker, {\n\t\tparamsCodec: forgejoRepoChangeParamsCodec,\n\t\tlauncher: launcher.launcher,\n\t\tworkflow: launcher.workflow,\n\t\tpublication: { ...sharedSources.adapter, sources },\n\t\twatcher: {\n\t\t\tsource: forgejoIssueWatcherSource,\n\t\t\tpreparationChecks: launcher.preparationChecks,\n\t\t\tresolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,\n\t\t},\n\t});\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAElC,SAAS,6BAA6B;;;ACHtC;AAAA,EACC;AAAA,EAEA;AAAA,OACM;AAMP,SAAS,oCAA4D;;;ACVrE;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AA4BA,SAAS,cACf,QAC+D;AAC/D,SAAO,OAAO,WAAW;AAC1B;AAGO,IAAM,+BACZ,kCAA2D;AAAA,EAC1D,UAAU,OAAO;AAChB,WAAO,qCAAqC,OAAO,uBAAuB;AAAA,MACzE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF;AACD,CAAC;;;ACpDF,SAAS,sCAAsC;AAaxC,SAAS,qBAAqB,KAA+B;AACnE,SAAO,+BAA+B,KAAK,uBAAuB;AAAA,IACjE,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,EACnB,CAAC;AACF;AAEO,SAAS,sBAAsB,UAA2B,SAAiC;AACjG,SAAO,OAAO,OAAO,UAAU,OAAO,IACnC,EAAE,GAAG,SAAS,OAAO,EAAE,IACvB,EAAE,mBAAmB,SAAS,kBAAkB,QAAQ;AAC5D;;;AFPO,IAAM,gCAAgC;AAGtC,SAAS,wBACf,YACA,OAI0B;AAC1B,SAAO;AAAA,IACN,aAAa,WAAW;AAAA,IACxB,YAAY,WAAW;AAAA,IACvB,YAAY,MAAM;AAAA,IAClB,QAAQ,MAAM;AAAA,IACd,gBAAgB,MAAM;AAAA,IACtB,mBAAmB,MAAM;AAAA,IACzB,kBAAkB,MAAM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Q,iBAAiB;AAC5C,YAAM,aAAa,IAAI,QAAQ,qBAAqB;AACpD,UAAI,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,UAAU;AAC9E,cAAM,IAAI,MAAM,mDAAmD;AACpE,eAAS,UAAU;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,iBAAiB,qBAAqB,MAAM;AAAA,MAC7C,CAAC;AACD,UAAI,OAAO,MAAM,SAAS,UAAU,IAAI,CAAC;AAAA,IAC1C;AAAA,EACD;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA;AAAA,EACD;AACD;AAKA,IAAM,EAAE,WAAW,iBAAiB,IAAI,wBAAwB,EAAE,QAAQ,KAAK,CAAC;AAChF,IAAO,gBAAQ;","names":[]}
@@ -1,26 +1,19 @@
1
+ import { type PullRequestChangeLaunchInput } from "@leitwerk-dev/coding/repository-change-launch";
1
2
  import type { ForgejoGitIdentity, ForgejoIntegration, ForgejoRepository } from "@leitwerk-dev/forgejo";
2
3
  import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
- import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
5
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
5
6
  import { type ForgejoRepoChangeParams } from "./params.js";
6
7
  import { type ProfileBindings } from "./profile-bindings.js";
7
8
  /** @internal */
8
9
  export declare const forgejoRepoChangeUiLauncherId: "forgejo_repo_change_process.ui_launcher";
9
10
  /** @internal */
10
- export declare function forgejoRepoChangeParams(repository: ForgejoRepository, input: {
11
- /** @internal */
12
- profile: string;
11
+ export declare function forgejoRepoChangeParams(repository: ForgejoRepository, input: PullRequestChangeLaunchInput & {
13
12
  /** @internal */
14
13
  woodpeckerProfile: string;
15
- /** @internal */
16
- sshCredentialRef: string;
17
- /** @internal */
18
- prompt: string;
19
- /** @internal */
20
- workBranch: string;
21
14
  }): ForgejoRepoChangeParams;
22
15
  /** @internal */
23
- export declare function forgejoRepoChangeLaunchConfig(params: ForgejoRepoChangeParams, title: string, gitIdentity: ForgejoGitIdentity): ProcessLaunchConfig<ForgejoRepoChangeParams>;
16
+ export declare function forgejoRepoChangeLaunchConfig(params: ForgejoRepoChangeParams, title: string, gitIdentity: ForgejoGitIdentity, repository?: ForgejoRepository): ProcessLaunchConfig<ForgejoRepoChangeParams>;
24
17
  /** @internal */
25
18
  export interface LauncherDependencies {
26
19
  /** @internal */
@@ -34,15 +27,10 @@ export interface LauncherDependencies {
34
27
  }
35
28
  /** @internal */
36
29
  export declare function createForgejoRepoChangeLauncher(): {
37
- /** @internal */
38
- configure: (value: LauncherDependencies | null) => void;
39
- /** @internal */
40
- preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>) => readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[];
41
- /** @internal */
30
+ configure(value: LauncherDependencies | null): void;
31
+ preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>) => import("@leitwerk-dev/process-sdk").LaunchPreparationCheck<ForgejoRepoChangeParams>[];
42
32
  resolveProfiles: (profile: string) => import("./profile-bindings.js").ProfileBinding;
43
- /** @internal */
44
33
  resolveGitIdentity: (profile: string) => Promise<ForgejoGitIdentity>;
45
- /** @internal */
46
34
  launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<ForgejoRepoChangeParams> & {
47
35
  resolveIssueLaunchConfig(event: {
48
36
  profile: string;
@@ -51,5 +39,6 @@ export declare function createForgejoRepoChangeLauncher(): {
51
39
  labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
52
40
  }): Promise<ProcessLaunchConfig<ForgejoRepoChangeParams>>;
53
41
  };
42
+ workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<ForgejoRepoChangeParams>;
54
43
  };
55
44
  //# sourceMappingURL=launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,KAAK,uBAAuB,EAAiB,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,uBAAuB,CAAC;AAEpF,gBAAgB;AAChB,eAAO,MAAM,6BAA6B,EAAG,yCAAkD,CAAC;AAEhG,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,iBAAiB,EAC7B,KAAK,EAAE;IACN,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,GACC,uBAAuB,CAiBzB;AAED,gBAAgB;AAChB,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,kBAAkB,GAC7B,mBAAmB,CAAC,uBAAuB,CAAC,CA6B9C;AAED,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,gBAAgB;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB;IAChB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,gBAAgB;IA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uBAAuB,EAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,kBAAkB,EAC/B,UAAU,CAAC,EAAE,iBAAiB,GAC5B,mBAAmB,CAAC,uBAAuB,CAAC,CAe9C;AAED,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,gBAAgB;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB;IAChB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,gBAAgB;IAChB,UAAU,EAAE,qBAAqB,CAAC;IAClC,gBAAgB;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B;;;;;;;;;;;;;;EAwB9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAG1F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAwBrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHAmIf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAG1F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAIrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHA+Ef"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/forgejo-repo-change",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -20,12 +20,12 @@
20
20
  "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
21
21
  },
22
22
  "dependencies": {
23
- "@leitwerk-dev/coding": "0.3.1",
24
- "@leitwerk-dev/external-writes": "0.3.1",
25
- "@leitwerk-dev/git-ssh": "0.3.1",
26
- "@leitwerk-dev/process-sdk": "0.3.1",
27
- "@leitwerk-dev/forgejo": "0.3.1",
28
- "@leitwerk-dev/woodpecker": "0.3.1"
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/forgejo": "0.4.0",
28
+ "@leitwerk-dev/woodpecker": "0.4.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "tsup": "^8.5.1"
package/src/launcher.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
- createRepositoryChangeUiLauncher,
3
- repositoryVisibilityCheck,
2
+ createRepositoryChangeLauncher,
3
+ type PullRequestChangeLaunchInput,
4
+ repositoryIssueChangeLaunchConfig,
4
5
  } from "@leitwerk-dev/coding/repository-change-launch";
5
6
  import type {
6
7
  ForgejoGitIdentity,
@@ -8,7 +9,7 @@ import type {
8
9
  ForgejoRepository,
9
10
  } from "@leitwerk-dev/forgejo";
10
11
  import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
11
- import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
12
+ import type { ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
12
13
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
13
14
  import { type ForgejoRepoChangeParams, isIssueOrigin } from "./params.js";
14
15
  import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
@@ -19,17 +20,9 @@ export const forgejoRepoChangeUiLauncherId = "forgejo_repo_change_process.ui_lau
19
20
  /** @internal */
20
21
  export function forgejoRepoChangeParams(
21
22
  repository: ForgejoRepository,
22
- input: {
23
- /** @internal */
24
- profile: string;
23
+ input: PullRequestChangeLaunchInput & {
25
24
  /** @internal */
26
25
  woodpeckerProfile: string;
27
- /** @internal */
28
- sshCredentialRef: string;
29
- /** @internal */
30
- prompt: string;
31
- /** @internal */
32
- workBranch: string;
33
26
  },
34
27
  ): ForgejoRepoChangeParams {
35
28
  return {
@@ -55,35 +48,22 @@ export function forgejoRepoChangeLaunchConfig(
55
48
  params: ForgejoRepoChangeParams,
56
49
  title: string,
57
50
  gitIdentity: ForgejoGitIdentity,
51
+ repository?: ForgejoRepository,
58
52
  ): ProcessLaunchConfig<ForgejoRepoChangeParams> {
59
53
  const { owner, repo, forgejoProfile: profile, woodpeckerProfile } = params;
60
54
  const issue = isIssueOrigin(params);
61
- return {
62
- processId: "forgejo_repo_change_process",
55
+ return repositoryIssueChangeLaunchConfig(
56
+ "forgejo",
63
57
  params,
64
58
  title,
65
- startTurnId: "generate_plan",
66
- ...(issue
67
- ? {
68
- externalId: `forgejo:${owner}/${repo}#${params.issueNumber}`,
69
- externalUrl: params.issueUrl,
70
- }
71
- : {}),
72
- projects: [
73
- {
74
- key: "repo",
75
- repoLocator: params.repoLocator,
76
- baseBranch: params.baseBranch,
77
- workBranch: params.workBranch,
78
- ...(issue ? { externalId: String(params.issueNumber), externalUrl: params.issueUrl } : {}),
79
- metadata: {
80
- forgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
81
- woodpecker: { owner, repo, profile: woodpeckerProfile },
82
- "leitwerk.gitIdentity": gitIdentity,
83
- },
84
- },
85
- ],
86
- };
59
+ `${owner}/${repo}`,
60
+ {
61
+ forgejo: { owner, repo, profile, ...(issue ? { issueNumber: params.issueNumber } : {}) },
62
+ woodpecker: { owner, repo, profile: woodpeckerProfile },
63
+ "leitwerk.gitIdentity": gitIdentity,
64
+ },
65
+ repository,
66
+ );
87
67
  }
88
68
 
89
69
  /** @internal */
@@ -100,86 +80,27 @@ export interface LauncherDependencies {
100
80
 
101
81
  /** @internal */
102
82
  export function createForgejoRepoChangeLauncher() {
103
- let dependencies: LauncherDependencies | null = null;
104
-
105
- /** @internal */
106
- function configureForgejoRepoChangeLauncher(value: LauncherDependencies | null): void {
107
- dependencies = value;
108
- }
109
-
110
- function requireDependencies(): LauncherDependencies {
111
- if (!dependencies) throw new Error("Forgejo repository launcher is not configured");
112
- return dependencies;
113
- }
114
-
115
- /** @internal */
116
- function forgejoRepositoryPreparationChecks(
117
- _input: unknown,
118
- { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>,
119
- ): readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[] {
120
- return [
121
- repositoryVisibilityCheck("Forgejo", async () =>
122
- (await repositories(params.forgejoProfile)).some(
123
- (candidate) => candidate.full_name === `${params.owner}/${params.repo}`,
124
- ),
125
- ),
126
- createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
127
- createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh),
128
- ];
129
- }
130
-
131
- /** @internal */
132
- function resolveProfiles(profile: string) {
133
- const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
134
- if (!forgejo.profiles().includes(profile)) throw new Error("Forgejo profile is not available");
135
- const binding = resolveProfileBinding(profileBindings, profile);
136
- try {
137
- woodpecker.client(binding.woodpeckerProfile);
138
- } catch {
139
- throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
140
- }
141
- if (!gitSsh.profiles().includes(binding.sshCredentialRef))
142
- throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
143
- return binding;
144
- }
145
-
146
- /** @internal */
147
- async function resolveForgejoGitIdentity(profile: string): Promise<ForgejoGitIdentity> {
148
- if (!profile) throw new Error("A Forgejo profile is required to resolve Git identity");
149
- return requireDependencies().forgejo.client(profile).resolveGitIdentity(profile);
150
- }
151
-
152
- async function repositories(profile: string): Promise<readonly ForgejoRepository[]> {
153
- if (!profile) return [];
154
- const { forgejo } = requireDependencies();
155
- if (!forgejo.profiles().includes(profile)) return [];
156
- return forgejo.client(profile).listRepositories();
157
- }
158
-
159
- const forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
83
+ return createRepositoryChangeLauncher({
160
84
  id: forgejoRepoChangeUiLauncherId,
161
85
  provider: "Forgejo",
162
86
  providerId: "forgejo",
163
- assertConfigured: requireDependencies,
164
- profiles: () => requireDependencies().forgejo.profiles(),
165
- repositories,
166
- resolveProfiles,
167
- resolveGitIdentity: resolveForgejoGitIdentity,
87
+ integration: (deps: LauncherDependencies) => deps.forgejo,
88
+ profile: (params: ForgejoRepoChangeParams) => params.forgejoProfile,
168
89
  params: forgejoRepoChangeParams,
169
90
  launchConfig: forgejoRepoChangeLaunchConfig,
170
- preparationChecks: forgejoRepositoryPreparationChecks,
91
+ resolveProfiles(profile, { woodpecker, gitSsh, profileBindings = {} }) {
92
+ const binding = resolveProfileBinding(profileBindings, profile);
93
+ try {
94
+ woodpecker.client(binding.woodpeckerProfile);
95
+ } catch {
96
+ throw new Error(`Woodpecker profile '${binding.woodpeckerProfile}' is not available`);
97
+ }
98
+ if (!gitSsh.profiles().includes(binding.sshCredentialRef))
99
+ throw new Error(`Git SSH profile '${binding.sshCredentialRef}' is not available`);
100
+ return binding;
101
+ },
102
+ preparationChecks: (params, dependencies) => [
103
+ createGitSshPreparationCheck("write", params, () => dependencies().gitSsh),
104
+ ],
171
105
  });
172
-
173
- return {
174
- /** @internal */
175
- configure: configureForgejoRepoChangeLauncher,
176
- /** @internal */
177
- preparationChecks: forgejoRepositoryPreparationChecks,
178
- /** @internal */
179
- resolveProfiles,
180
- /** @internal */
181
- resolveGitIdentity: resolveForgejoGitIdentity,
182
- /** @internal */
183
- launcher: forgejoRepoChangeUiLauncher,
184
- };
185
106
  }
package/src/process.ts CHANGED
@@ -1,14 +1,10 @@
1
- import { createRepositoryChangeProcess } from "@leitwerk-dev/coding";
2
1
  import {
3
- createRepositoryChangePublication,
2
+ createPullRequestChangeProcess,
4
3
  publicationObject as object,
5
4
  type PublicationSource,
6
5
  type PublicationState,
7
- pullRequestPublicationCallbacks,
8
- pullRequestPublicationSources,
6
+ pullRequestPublicationDefaults,
9
7
  readPublicationState,
10
- reconcilePullRequestSourceIssue,
11
- resolvePullRequestGitIdentity,
12
8
  } from "@leitwerk-dev/coding/repository-change-publication";
13
9
  import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
14
10
  import { forgejoExternal, forgejoIssueWatcherSource } from "@leitwerk-dev/forgejo";
@@ -20,39 +16,33 @@ import {
20
16
  isIssueOrigin,
21
17
  } from "./params.js";
22
18
 
23
- const processId = "forgejo_repo_change_process";
24
- const ids = {
25
- deliver: "deliver_change",
26
- feedback: "revise_from_pull_request_feedback",
27
- ciRepair: "repair_woodpecker_pipeline",
28
- operator: "ci_operator_action",
29
- };
30
19
  const remote = (state: RepositoryChangeState) => readPublicationState(state, "forgejoRepoChange");
31
20
 
32
- const deliveryTools = [
33
- "forgejo_get_pull_request",
34
- "forgejo_add_pull_request_comment",
35
- "forgejo_resolve_git_identity",
36
- "forgejo_ensure_pull_request",
37
- "forgejo_add_issue_comment",
38
- "forgejo_add_pull_request_feedback_reaction",
39
- "forgejo_reply_to_pull_request_feedback",
40
- "forgejo_get_issue",
41
- "forgejo_ensure_label",
42
- "forgejo_update_issue",
43
- ] as const;
44
-
45
21
  /** @internal */
46
22
  export function createForgejoRepoChangeProcess(
47
23
  launcher: ReturnType<typeof createForgejoRepoChangeLauncher>,
48
24
  docker: boolean,
49
25
  ) {
50
- const sharedSources = pullRequestPublicationSources<ForgejoRepoChangeParams>(
26
+ const sharedSources = pullRequestPublicationDefaults<ForgejoRepoChangeParams>(
51
27
  "forgejo",
52
28
  "Forgejo",
53
29
  forgejoExternal,
54
30
  (params) => params.forgejoProfile,
55
31
  (params) => (isIssueOrigin(params) ? params : undefined),
32
+ "id",
33
+ {
34
+ id: "repair_woodpecker_pipeline",
35
+ label: "Woodpecker pipeline",
36
+ tools: [
37
+ "woodpecker_lookup_repository",
38
+ "woodpecker_list_pipelines",
39
+ "woodpecker_get_pipeline",
40
+ "woodpecker_get_step_logs",
41
+ "woodpecker_restart_pipeline",
42
+ ],
43
+ prompt: (current) =>
44
+ `Diagnose Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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.`,
45
+ },
56
46
  );
57
47
  const { requirePr } = sharedSources;
58
48
  const failedPipeline = woodpeckerExternal.pipeline<
@@ -73,11 +63,8 @@ export function createForgejoRepoChangeProcess(
73
63
  });
74
64
 
75
65
  const sources: PublicationSource<ForgejoRepoChangeParams>[] = [
76
- {
77
- id: "forgejo_merge_conflict",
78
- kind: "conflict",
79
- label: "Rebase conflicting pull request",
80
- source: forgejoExternal.pullRequestConflict(({ params, state }) => ({
66
+ sharedSources.conflict(
67
+ forgejoExternal.pullRequestConflict(({ params, state }) => ({
81
68
  profile: params.forgejoProfile,
82
69
  owner: params.owner,
83
70
  repo: params.repo,
@@ -86,11 +73,7 @@ export function createForgejoRepoChangeProcess(
86
73
  lastConflictKey: remote(state).lastConflictKey,
87
74
  pollInterval: "30s",
88
75
  })),
89
- read: ({ event }) => ({
90
- kind: "conflict",
91
- conflict: object(event).conflict as NonNullable<PublicationState["conflict"]>,
92
- }),
93
- },
76
+ ),
94
77
  sharedSources.feedback,
95
78
  {
96
79
  id: "woodpecker_failure_repair",
@@ -106,74 +89,15 @@ export function createForgejoRepoChangeProcess(
106
89
  ...sharedSources.terminal,
107
90
  sharedSources.cancelled,
108
91
  ];
109
- const publicationConfig = createRepositoryChangePublication<ForgejoRepoChangeParams>({
110
- namespace: "forgejoRepoChange",
111
- label: "Forgejo PR",
112
- ids,
113
- sources,
114
- tools: {
115
- delivery: deliveryTools,
116
- feedback: ["forgejo_get_pull_request", "forgejo_list_pull_request_feedback"],
117
- ci: [
118
- "woodpecker_lookup_repository",
119
- "woodpecker_list_pipelines",
120
- "woodpecker_get_pipeline",
121
- "woodpecker_get_step_logs",
122
- "woodpecker_restart_pipeline",
123
- ],
124
- },
125
- identity: (ctx) => resolvePullRequestGitIdentity(ctx, "forgejo", ctx.params.forgejoProfile),
126
- reconcileTerminal: reconcilePullRequestSourceIssue<ForgejoRepoChangeParams>(
127
- "forgejo",
128
- "id",
129
- (params) => (isIssueOrigin(params) ? params : undefined),
130
- ),
131
- ...pullRequestPublicationCallbacks<ForgejoRepoChangeParams>("forgejo", "Forgejo", (params) =>
132
- isIssueOrigin(params) ? params : undefined,
133
- ),
134
- commitMessage: (kind) =>
135
- kind === "feedback"
136
- ? "fix: address Forgejo review feedback"
137
- : "fix: repair Woodpecker pipeline",
138
- prompt(kind, current) {
139
- return kind === "feedback"
140
- ? `Address the unseen Forgejo pull-request feedback batch for PR #${current.prNumber}. Feedback identifiers: ${JSON.stringify(current.feedbackIds)}. Inspect the current checkout and use Forgejo 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.`
141
- : `Diagnose Woodpecker pipeline #${current.pipeline?.number ?? "unknown"} (${current.pipeline?.status ?? "unknown"}) for the current checkout. Use Woodpecker tools to inspect pipeline metadata and bounded failed-step 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.`;
142
- },
143
- });
144
- const publication = publicationConfig.fragment;
145
- publication.watcher({
146
- id: "use_leitwerk",
147
- label: "Forgejo use-leitwerk issues",
148
- description: "Launch a remote repository change for Forgejo issues carrying the trigger label",
149
- source: forgejoIssueWatcherSource,
150
- preparationChecks: launcher.preparationChecks,
151
- resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,
152
- });
153
-
154
- const definition = createRepositoryChangeProcess<ForgejoRepoChangeParams>({
155
- processId,
156
- displayName: "Forgejo Repo Change",
92
+ return createPullRequestChangeProcess("forgejo", "Forgejo", docker, {
157
93
  paramsCodec: forgejoRepoChangeParamsCodec,
158
94
  launcher: launcher.launcher,
159
- finalizeLabel: "Publish pull request",
160
- finalizeForm: {
161
- id: "forgejo_publish",
162
- title: "Publish pull request",
163
- fields: [],
164
- submitLabel: "Publish",
95
+ workflow: launcher.workflow,
96
+ publication: { ...sharedSources.adapter, sources },
97
+ watcher: {
98
+ source: forgejoIssueWatcherSource,
99
+ preparationChecks: launcher.preparationChecks,
100
+ resolveLaunchConfig: launcher.launcher.resolveIssueLaunchConfig,
165
101
  },
166
- repositoryCredentials: ({ params }) => [
167
- {
168
- projectKey: "repo",
169
- kind: "git_ssh",
170
- credentialRef: params.sshCredentialRef,
171
- },
172
- ],
173
- publication: publicationConfig,
174
102
  });
175
-
176
- definition.process.runtime = { ...definition.process.runtime, docker };
177
-
178
- return definition.process;
179
103
  }