@leitwerk-dev/gitlab-repo-change 0.3.0 → 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.
@@ -1,12 +1,15 @@
1
+ import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
1
2
  import { type GitLabIntegration, type GitLabIssueWatcherEvent } from "@leitwerk-dev/gitlab";
2
3
  import { type LaunchPreparationCheck, type ProcessLaunchConfig, type ProcessLauncherDefinition } from "@leitwerk-dev/process-sdk";
3
4
  import type { GitLabRepoChangeParams } from "./params.js";
4
5
  /** @public */
5
6
  export declare function createGitLabRepoChangeLauncher(): {
6
7
  /** @public */
7
- configure: (value: GitLabIntegration | null) => void;
8
+ configure: (value: GitLabIntegration | null, sshIntegration?: GitSshIntegration | null) => void;
8
9
  /** @public */
9
10
  launcher: ProcessLauncherDefinition<GitLabRepoChangeParams>;
11
+ /** Server-side routing policies. @public */
12
+ workflow: import("@leitwerk-dev/coding/repository-change-launch").RepositoryChangeWorkflow<GitLabRepoChangeParams>;
10
13
  /** @public */
11
14
  preparationChecks: (_input: unknown, { params }: ProcessLaunchConfig<GitLabRepoChangeParams>) => readonly LaunchPreparationCheck<GitLabRepoChangeParams>[];
12
15
  /** @public */
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAG5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,cAAc;AACd,wBAAgB,8BAA8B;IA+M5C,cAAc;uBAzMW,iBAAiB,GAAG,IAAI;IA2MjD,cAAc;;IAEd,cAAc;gCAzHN,OAAO,cACH,mBAAmB,CAAC,sBAAsB,CAAC,KACrD,SAAS,sBAAsB,CAAC,sBAAsB,CAAC,EAAE;IAyH3D,cAAc;qBACS,uBAAuB;EAS/C"}
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAOA,OAAO,EAAgC,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAI5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc;AACd,wBAAgB,8BAA8B;IAgO5C,cAAc;uBAxNP,iBAAiB,GAAG,IAAI,mBACf,iBAAiB,GAAG,IAAI;IA0NxC,cAAc;;IAEd,4CAA4C;;IAS5C,cAAc;gCA9JN,OAAO,cACH,mBAAmB,CAAC,sBAAsB,CAAC,KACrD,SAAS,sBAAsB,CAAC,sBAAsB,CAAC,EAAE;IA+J3D,cAAc;qBACS,uBAAuB;EAS/C"}
package/dist/params.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { type RepositoryChangeLaunchParams } from "@leitwerk-dev/coding/repository-change-launch";
1
+ import { type RepositoryChangeLaunchParams, type RepositoryIssueOriginParams, type RepositoryUiOriginParams } from "@leitwerk-dev/coding/repository-change-launch";
2
2
  /** @public */
3
3
  export type GitLabRepoChangeParams = RepositoryChangeLaunchParams<{
4
4
  /** @public */
5
5
  gitlabProfile: string;
6
6
  /** @public */
7
+ gitSshProfile?: string;
8
+ /** @public */
7
9
  gitlabOrigin: string;
8
10
  /** @public */
9
11
  projectId: number;
@@ -11,29 +13,7 @@ export type GitLabRepoChangeParams = RepositoryChangeLaunchParams<{
11
13
  owner: string;
12
14
  /** @public */
13
15
  repo: string;
14
- } /** @public */ /** @public */ & ({
15
- /** @public */
16
- origin: "ui";
17
- /** @public */
18
- issueNumber: null;
19
- /** @public */
20
- issueUrl: null;
21
- /** @public */
22
- triggerLabel: null;
23
- /** @public */
24
- doneLabel: null;
25
- } | {
26
- /** @public */
27
- origin: "issue";
28
- /** @public */
29
- issueNumber: number;
30
- /** @public */
31
- issueUrl: string;
32
- /** @public */
33
- triggerLabel: string;
34
- /** @public */
35
- doneLabel: string;
36
- })>;
16
+ } & (RepositoryUiOriginParams | RepositoryIssueOriginParams)>;
37
17
  /** @public */
38
18
  export declare const gitlabRepoChangeParamsCodec: import("@leitwerk-dev/process-sdk").Codec<GitLabRepoChangeParams>;
39
19
  //# sourceMappingURL=params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EAEjC,MAAM,+CAA+C,CAAC;AAEvD,cAAc;AACd,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,CAChE;IACC,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;CACb,CAAC,cAAc,CAAC,cAAc,GAAG,CAC/B;IACA,cAAc;IACd,MAAM,EAAE,IAAI,CAAC;IACb,cAAc;IACd,WAAW,EAAE,IAAI,CAAC;IAClB,cAAc;IACd,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc;IACd,YAAY,EAAE,IAAI,CAAC;IACnB,cAAc;IACd,SAAS,EAAE,IAAI,CAAC;CACf,GACD;IACA,cAAc;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;CACjB,CACH,CACD,CAAC;AACF,cAAc;AACd,eAAO,MAAM,2BAA2B,mEA4CrC,CAAC"}
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAE7B,MAAM,+CAA+C,CAAC;AAGvD,cAAc;AACd,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,CAChE;IACC,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IAEtB,cAAc;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IAErB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IAEd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;CACb,GAAG,CAAC,wBAAwB,GAAG,2BAA2B,CAAC,CAC5D,CAAC;AAEF,cAAc;AACd,eAAO,MAAM,2BAA2B,mEA6CrC,CAAC"}
package/dist/process.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { type PublicationEvidence } from "@leitwerk-dev/coding/repository-change-publication";
2
2
  import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
3
3
  import { type GitLabDeliveryObservation } from "@leitwerk-dev/gitlab";
4
+ import type { ExtensionProcessDefinition, ServerExtensionAPI } from "@leitwerk-dev/process-sdk";
4
5
  import type { createGitLabRepoChangeLauncher } from "./launcher.js";
5
6
  import { type GitLabRepoChangeParams } from "./params.js";
7
+ /** @internal */
8
+ export declare function registerGitLabRepoChangeMaintenance(api: ServerExtensionAPI, process: ExtensionProcessDefinition<GitLabRepoChangeParams, RepositoryChangeState>): void;
6
9
  /** @public */
7
10
  export declare function gitlabPublicationEvidence(state: RepositoryChangeState, event: GitLabDeliveryObservation): PublicationEvidence;
8
11
  /** @public */
9
- export declare function createGitLabRepoChangeProcess(launcher: ReturnType<typeof createGitLabRepoChangeLauncher>, docker: boolean): import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<GitLabRepoChangeParams, RepositoryChangeState>;
12
+ export declare function createGitLabRepoChangeProcess(launcher: ReturnType<typeof createGitLabRepoChangeLauncher>, docker: boolean): ExtensionProcessDefinition<GitLabRepoChangeParams, RepositoryChangeState>;
10
13
  //# sourceMappingURL=process.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,mBAAmB,EAIxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EACN,KAAK,yBAAyB,EAK9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAA+B,MAAM,aAAa,CAAC;AAmBvF,cAAc;AACd,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,yBAAyB,GAC9B,mBAAmB,CAuBrB;AACD,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,iHAmLf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,mBAAmB,EAGxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAEN,KAAK,yBAAyB,EAI9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAA+B,MAAM,aAAa,CAAC;AAOvF,gBAAgB;AAChB,wBAAgB,mCAAmC,CAClD,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,0BAA0B,CAAC,sBAAsB,EAAE,qBAAqB,CAAC,GAChF,IAAI,CAEN;AAQD,cAAc;AACd,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,yBAAyB,GAC9B,mBAAmB,CAErB;AAED,cAAc;AACd,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,EAC3D,MAAM,EAAE,OAAO,6EAsDf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/gitlab-repo-change",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -20,14 +20,15 @@
20
20
  "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
21
21
  },
22
22
  "dependencies": {
23
- "@leitwerk-dev/coding": "0.3.0",
24
- "@leitwerk-dev/external-writes": "0.3.0",
25
- "@leitwerk-dev/process-sdk": "0.3.0",
26
- "@leitwerk-dev/gitlab": "0.3.0",
27
- "@leitwerk-dev/repository-rebase": "0.3.0"
23
+ "@leitwerk-dev/coding": "0.4.0",
24
+ "@leitwerk-dev/external-writes": "0.4.0",
25
+ "@leitwerk-dev/process-sdk": "0.4.0",
26
+ "@leitwerk-dev/gitlab": "0.4.0",
27
+ "@leitwerk-dev/git-ssh": "0.4.0"
28
28
  },
29
29
  "devDependencies": {
30
- "tsup": "^8.5.1"
30
+ "tsup": "^8.5.1",
31
+ "@leitwerk-dev/extension-runtime": "0.4.0"
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
@@ -47,6 +48,7 @@
47
48
  "!dist/**/*.test.*",
48
49
  "!src/**/*.test.ts",
49
50
  "!src/testing/**",
50
- "!dist/testing/**"
51
+ "!dist/testing/**",
52
+ "process.mmd"
51
53
  ]
52
54
  }
package/process.mmd ADDED
@@ -0,0 +1,43 @@
1
+ %% Generated from the registered process with toProcessGraphView.
2
+ flowchart TD
3
+ generate_plan["Plan<br/>llm"]
4
+ plan_decision{"Review Plan<br/>human"}
5
+ implement["Implement<br/>llm"]
6
+ simplify_implementation["Simplify<br/>llm"]
7
+ apply_simplification["Apply simplification<br/>llm"]
8
+ generate_commit_message["Write Commit Message<br/>llm"]
9
+ deliver_change["Deliver<br/>automatic"]
10
+ revise_from_merge_request_feedback["Address Feedback<br/>llm"]
11
+ repair_gitlab_pipeline["Fix CI<br/>llm"]
12
+ ci_operator_action{"Repository repair needs operator action<br/>human"}
13
+ completed([Completed])
14
+ aborted([Aborted])
15
+ generate_plan -- "approval" --> plan_decision
16
+ generate_plan -- "bypass" --> implement
17
+ plan_decision -- "approve_plan" --> implement
18
+ plan_decision -- "request_revision" --> generate_plan
19
+ implement -- "simplify" --> simplify_implementation
20
+ implement -- "skip" --> generate_commit_message
21
+ simplify_implementation -- "simplification-plan" --> apply_simplification
22
+ apply_simplification -- "implementation-summary" --> generate_commit_message
23
+ generate_commit_message -- "commit-message" --> deliver_change
24
+ deliver_change -- "awaiting" --> deliver_change
25
+ deliver_change -- "completed" --> completed
26
+ deliver_change -- "aborted" --> aborted
27
+ deliver_change -. "external:source_cancelled" .-> aborted
28
+ deliver_change -. "external:maintenance_feedback" .-> revise_from_merge_request_feedback
29
+ deliver_change -. "external:maintenance_conflict" .-> revise_from_merge_request_feedback
30
+ deliver_change -. "external:maintenance_ci" .-> repair_gitlab_pipeline
31
+ deliver_change -. "external:maintenance_operator" .-> ci_operator_action
32
+ revise_from_merge_request_feedback -- "changes_ready" --> deliver_change
33
+ revise_from_merge_request_feedback -- "no_changes" --> deliver_change
34
+ revise_from_merge_request_feedback -- "cannot_repair" --> ci_operator_action
35
+ repair_gitlab_pipeline -- "changes_ready" --> deliver_change
36
+ repair_gitlab_pipeline -- "no_changes" --> deliver_change
37
+ repair_gitlab_pipeline -- "cannot_repair" --> ci_operator_action
38
+ ci_operator_action -- "feedback" --> revise_from_merge_request_feedback
39
+ ci_operator_action -- "ci" --> repair_gitlab_pipeline
40
+ ci_operator_action -- "resume_waiting" --> deliver_change
41
+ ci_operator_action -- "abort" --> aborted
42
+ ci_operator_action -. "external:maintenance_feedback" .-> revise_from_merge_request_feedback
43
+ ci_operator_action -. "external:maintenance_conflict" .-> revise_from_merge_request_feedback
package/src/index.ts CHANGED
@@ -1,16 +1,21 @@
1
+ import { gitSshIntegration } from "@leitwerk-dev/git-ssh";
1
2
  import { gitlabIntegration } from "@leitwerk-dev/gitlab";
2
3
  import type { LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
3
4
  import { createGitLabRepoChangeLauncher } from "./launcher.js";
4
- import { createGitLabRepoChangeProcess } from "./process.js";
5
+ import { createGitLabRepoChangeProcess, registerGitLabRepoChangeMaintenance } from "./process.js";
6
+
5
7
  /** @public */
6
8
  export const manifest = {
7
9
  /** @public */
8
10
  id: "gitlab-repo-change",
11
+
9
12
  /** @public */
10
13
  version: "0.1.9",
14
+
11
15
  /** @public */
12
- requires: ["gitlab", "coding"],
16
+ requires: ["gitlab", "coding", "git-ssh"],
13
17
  } as const;
18
+
14
19
  /** @public */
15
20
  /** @public */
16
21
  export function createGitLabRepoChange(options: {
@@ -26,23 +31,30 @@ export function createGitLabRepoChange(options: {
26
31
  api.registerProcess(process);
27
32
  },
28
33
  setupServer(api) {
34
+ registerGitLabRepoChangeMaintenance(api, process);
29
35
  const integration = api.require(gitlabIntegration);
30
36
  if (Array.isArray(integration)) throw new Error("GitLab integration must be singular");
31
- launcher.configure(integration);
37
+ const ssh = api.require(gitSshIntegration);
38
+ if (Array.isArray(ssh)) throw new Error("Git SSH integration must be singular");
39
+ launcher.configure(integration, ssh);
32
40
  api.onStop(() => launcher.configure(null));
33
41
  },
34
42
  };
43
+
35
44
  /** @public */
36
45
  /** @public */
37
46
  return {
38
47
  /** @public */
39
48
  extension,
49
+
40
50
  /** @public */
41
51
  process,
52
+
42
53
  /** @public */
43
54
  launcher,
44
55
  };
45
56
  }
57
+
46
58
  /** @public */
47
59
  export const {
48
60
  extension: defaultExtension,
package/src/launcher.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
2
+ import {
3
+ repositoryChangeOptionFields,
4
+ repositoryChangeOptions,
5
+ repositoryChangeWorkflow,
6
+ } from "@leitwerk-dev/coding/repository-change-launch";
2
7
  import { trimString } from "@leitwerk-dev/domain";
8
+ import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
9
  import {
4
10
  type GitLabIntegration,
5
11
  type GitLabIssueWatcherEvent,
6
12
  type GitLabProject,
7
13
  gitlabIssueExternalId,
14
+ resolveGitLabLaunchProject,
8
15
  } from "@leitwerk-dev/gitlab";
9
16
  import {
10
17
  type LaunchPreparationCheck,
@@ -13,43 +20,56 @@ import {
13
20
  SafeLaunchPreparationError,
14
21
  } from "@leitwerk-dev/process-sdk";
15
22
  import type { GitLabRepoChangeParams } from "./params.js";
23
+
16
24
  /** @public */
17
25
  export function createGitLabRepoChangeLauncher() {
18
26
  let integration: GitLabIntegration | null = null;
27
+ let ssh: GitSshIntegration | null = null;
19
28
  const requireIntegration = () => {
20
29
  if (!integration) throw new Error("GitLab repository launcher is not configured");
21
30
  return integration;
22
31
  };
23
- const configure = (value: GitLabIntegration | null) => {
32
+ const configure = (
33
+ value: GitLabIntegration | null,
34
+ sshIntegration: GitSshIntegration | null = null,
35
+ ) => {
24
36
  integration = value;
37
+ ssh = sshIntegration;
25
38
  };
26
39
  async function launch(
27
40
  repository: GitLabProject,
28
41
  profile: string,
29
42
  prompt: string,
30
43
  issue?: GitLabIssueWatcherEvent,
44
+ options: {
45
+ skipPlanDecision?: boolean;
46
+ skipSimplification?: boolean;
47
+ gitSshProfile?: string;
48
+ } = {},
31
49
  ): Promise<ProcessLaunchConfig<GitLabRepoChangeParams>> {
32
50
  const service = requireIntegration();
33
51
  if (!service.profiles().includes(profile)) throw new Error("GitLab profile is unavailable");
34
52
  const client = service.client(profile);
35
- const split = repository.path_with_namespace.lastIndexOf("/");
36
- if (split < 1) throw new Error("Invalid GitLab project path");
37
- const common = {
38
- gitlabProfile: profile,
39
- gitlabOrigin: client.baseUrl,
40
- projectId: repository.id,
41
- owner: repository.path_with_namespace.slice(0, split),
42
- repo: repository.path_with_namespace.slice(split + 1),
43
- repoLocator: repository.http_url_to_repo,
44
- baseBranch: repository.default_branch,
45
- workBranch: issue
53
+ const gitSshProfile =
54
+ options.gitSshProfile ??
55
+ issue?.gitSshProfile ??
56
+ (ssh?.profiles().length === 1 ? ssh.profiles()[0] : "");
57
+ if (!gitSshProfile || !ssh?.profiles().includes(gitSshProfile))
58
+ throw new Error("Select a matching Git SSH profile");
59
+ const { params: binding, project } = await resolveGitLabLaunchProject(
60
+ client,
61
+ profile,
62
+ repository,
63
+ issue
46
64
  ? `leitwerk/issue-${issue.issue.iid}`
47
65
  : buildAutoWorkBranchFromSeed(
48
66
  prompt,
49
67
  `${repository.http_url_to_repo}:${repository.default_branch}`,
50
68
  ),
51
- prompt,
52
- };
69
+ );
70
+ project.settingsRepository.origin = new URL(repository.web_url).origin;
71
+ if (issue) Object.assign(project.metadata.gitlab, { issueIid: issue.issue.iid });
72
+ const common = { ...binding, gitSshProfile, ...repositoryChangeOptions(options), prompt };
53
73
  const params: GitLabRepoChangeParams = issue
54
74
  ? {
55
75
  ...common,
@@ -67,7 +87,6 @@ export function createGitLabRepoChangeLauncher() {
67
87
  triggerLabel: null,
68
88
  doneLabel: null,
69
89
  };
70
- const identity = await client.resolveGitIdentity();
71
90
  return {
72
91
  processId: "gitlab_repo_change_process",
73
92
  title: issue?.issue.title ?? prompt,
@@ -79,28 +98,7 @@ export function createGitLabRepoChangeLauncher() {
79
98
  externalUrl: issue.issue.web_url,
80
99
  }
81
100
  : {}),
82
- projects: [
83
- {
84
- key: "repo",
85
- repoLocator: params.repoLocator,
86
- baseBranch: params.baseBranch,
87
- workBranch: params.workBranch,
88
- metadata: {
89
- gitlab: {
90
- profile,
91
- projectId: repository.id,
92
- ...(issue ? { issueIid: issue.issue.iid } : {}),
93
- },
94
- "leitwerk.gitIdentity": {
95
- provider: "gitlab",
96
- profile,
97
- login: identity.username,
98
- name: identity.name,
99
- email: identity.email,
100
- },
101
- },
102
- },
103
- ],
101
+ projects: [project],
104
102
  };
105
103
  }
106
104
  const preparationChecks = (
@@ -109,27 +107,29 @@ export function createGitLabRepoChangeLauncher() {
109
107
  ): readonly LaunchPreparationCheck<GitLabRepoChangeParams>[] => [
110
108
  {
111
109
  id: "gitlab_repository_access",
112
- label: "Verify GitLab repository and HTTPS read/write access",
110
+ label: "Verify GitLab repository access",
113
111
  async run({ signal }) {
114
112
  const client = requireIntegration().client(params.gitlabProfile);
115
113
  const repository = await client.getProject(params.projectId, signal);
116
114
  if (
117
115
  repository.archived ||
118
- repository.http_url_to_repo !== params.repoLocator ||
116
+ repository.ssh_url_to_repo !== params.repoLocator ||
119
117
  repository.default_branch !== params.baseBranch
120
118
  )
121
119
  throw new SafeLaunchPreparationError(
122
120
  "Repository changed or is archived",
123
121
  "Select an active GitLab project and launch again.",
124
122
  );
125
- await client.preflightRepository(
126
- params.projectId,
127
- params.baseBranch,
128
- params.workBranch,
129
- signal,
130
- );
131
123
  },
132
124
  },
125
+ createGitSshPreparationCheck(
126
+ "write",
127
+ { ...params, sshCredentialRef: params.gitSshProfile ?? "" },
128
+ () => {
129
+ if (!params.gitSshProfile || !ssh) throw new Error("Git SSH profile is unavailable");
130
+ return ssh;
131
+ },
132
+ ),
133
133
  ];
134
134
  const launcher: ProcessLauncherDefinition<GitLabRepoChangeParams> = {
135
135
  id: "gitlab_repo_change_process.ui_launcher",
@@ -147,7 +147,15 @@ export function createGitLabRepoChangeLauncher() {
147
147
  fields: [
148
148
  { id: "gitlabProfile", label: "GitLab profile", kind: "select", required: true },
149
149
  { id: "repository", label: "Project", kind: "select", required: true },
150
+ {
151
+ id: "gitSshProfile",
152
+ label: "Git SSH profile",
153
+ kind: "select",
154
+ required: true,
155
+ options: [],
156
+ },
150
157
  { id: "prompt", label: "Requested change", kind: "textarea", required: true },
158
+ ...repositoryChangeOptionFields,
151
159
  ],
152
160
  submitLabel: "Start change",
153
161
  },
@@ -155,13 +163,16 @@ export function createGitLabRepoChangeLauncher() {
155
163
  return {
156
164
  gitlabProfile: requireIntegration().profiles()[0] ?? "",
157
165
  repository: "",
166
+ gitSshProfile: ssh?.profiles()[0] ?? "",
158
167
  prompt: "",
168
+ ...repositoryChangeOptions({}),
159
169
  };
160
170
  },
161
171
  async resolveOptions(input) {
162
172
  const i = requireIntegration();
163
173
  const profile = trimString(input.gitlabProfile);
164
174
  return {
175
+ gitSshProfile: (ssh?.profiles() ?? []).map((value) => ({ value, label: value })),
165
176
  gitlabProfile: i.profiles().map((value) => ({ value, label: value })),
166
177
  repository: (i.profiles().includes(profile) ? await i.client(profile).listProjects() : [])
167
178
  .filter((p) => !p.archived && p.default_branch)
@@ -178,6 +189,8 @@ export function createGitLabRepoChangeLauncher() {
178
189
  gitlabProfile: trimString(input.gitlabProfile),
179
190
  repository: trimString(input.repository),
180
191
  prompt: trimString(input.prompt),
192
+ gitSshProfile: trimString(input.gitSshProfile),
193
+ ...repositoryChangeOptions(input),
181
194
  };
182
195
  },
183
196
  async resolveLaunchConfig(input) {
@@ -185,6 +198,12 @@ export function createGitLabRepoChangeLauncher() {
185
198
  const projectId = Number(input.repository);
186
199
  const prompt = trimString(input.prompt);
187
200
  const errors = [];
201
+ if (!ssh?.profiles().includes(trimString(input.gitSshProfile)))
202
+ errors.push({
203
+ fieldId: "gitSshProfile",
204
+ message: "Select an available Git SSH profile",
205
+ code: "custom_rule" as const,
206
+ });
188
207
  if (!requireIntegration().profiles().includes(profile))
189
208
  errors.push({
190
209
  fieldId: "gitlabProfile",
@@ -216,17 +235,34 @@ export function createGitLabRepoChangeLauncher() {
216
235
  },
217
236
  ],
218
237
  };
219
- return { ok: true, launchConfig: await launch(repository, profile, prompt) };
238
+ return {
239
+ ok: true,
240
+ launchConfig: await launch(repository, profile, prompt, undefined, {
241
+ gitSshProfile: trimString(input.gitSshProfile),
242
+ ...repositoryChangeOptions(input),
243
+ }),
244
+ };
220
245
  },
221
246
  },
222
247
  };
223
248
  return {
224
249
  /** @public */
225
250
  configure,
251
+
226
252
  /** @public */
227
253
  launcher,
254
+ /** Server-side routing policies. @public */
255
+ workflow: repositoryChangeWorkflow(async (params: GitLabRepoChangeParams) => {
256
+ if (params.origin !== "issue") throw new Error("Missing GitLab source issue");
257
+ const client = requireIntegration().client(params.gitlabProfile);
258
+ if (client.baseUrl !== params.gitlabOrigin)
259
+ throw new Error("GitLab profile installation changed from the source issue");
260
+ return (await client.getIssue(params.projectId, params.issueNumber)).labels;
261
+ }),
262
+
228
263
  /** @public */
229
264
  preparationChecks,
265
+
230
266
  /** @public */
231
267
  async fromIssue(event: GitLabIssueWatcherEvent) {
232
268
  return launch(
package/src/params.ts CHANGED
@@ -2,49 +2,35 @@ import {
2
2
  createRepositoryChangeParamsCodec,
3
3
  normalizeRepositoryChangeParamsInput,
4
4
  type RepositoryChangeLaunchParams,
5
+ type RepositoryIssueOriginParams,
6
+ type RepositoryUiOriginParams,
5
7
  repositoryChangeParamsRecord,
6
8
  } from "@leitwerk-dev/coding/repository-change-launch";
7
9
  import { trimString } from "@leitwerk-dev/domain";
10
+
8
11
  /** @public */
9
12
  export type GitLabRepoChangeParams = RepositoryChangeLaunchParams<
10
13
  {
11
14
  /** @public */
12
15
  gitlabProfile: string;
16
+
17
+ /** @public */
18
+ gitSshProfile?: string;
19
+
13
20
  /** @public */
14
21
  gitlabOrigin: string;
22
+
15
23
  /** @public */
16
24
  projectId: number;
25
+
17
26
  /** @public */
18
27
  owner: string;
28
+
19
29
  /** @public */
20
30
  repo: string;
21
- } /** @public */ /** @public */ & (
22
- | {
23
- /** @public */
24
- origin: "ui";
25
- /** @public */
26
- issueNumber: null;
27
- /** @public */
28
- issueUrl: null;
29
- /** @public */
30
- triggerLabel: null;
31
- /** @public */
32
- doneLabel: null;
33
- }
34
- | {
35
- /** @public */
36
- origin: "issue";
37
- /** @public */
38
- issueNumber: number;
39
- /** @public */
40
- issueUrl: string;
41
- /** @public */
42
- triggerLabel: string;
43
- /** @public */
44
- doneLabel: string;
45
- }
46
- )
31
+ } & (RepositoryUiOriginParams | RepositoryIssueOriginParams)
47
32
  >;
33
+
48
34
  /** @public */
49
35
  export const gitlabRepoChangeParamsCodec =
50
36
  createRepositoryChangeParamsCodec<GitLabRepoChangeParams>({
@@ -60,6 +46,7 @@ export const gitlabRepoChangeParamsCodec =
60
46
  const common = {
61
47
  ...normalizeRepositoryChangeParamsInput(value, "GitLab Repo Change"),
62
48
  gitlabProfile: text("gitlabProfile"),
49
+ gitSshProfile: trimString(r.gitSshProfile),
63
50
  gitlabOrigin: text("gitlabOrigin"),
64
51
  projectId: r.projectId,
65
52
  owner: text("owner"),