@gitlab/opencode-gitlab-plugin 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
4
4
 
5
+ ## [1.2.0](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/compare/v1.1.0...v1.2.0) (2026-01-29)
6
+
7
+
8
+ ### ✨ Features
9
+
10
+ * **merge-requests:** add auto-merge (MWPS) tool using GraphQL API ([2bb3a21](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/commit/2bb3a2123058616cd27003f885ad4d4082e4b3a0))
11
+
5
12
  ## [1.1.0](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/compare/v1.0.6...v1.1.0) (2026-01-13)
6
13
 
7
14
 
package/dist/index.js CHANGED
@@ -83,6 +83,32 @@ var GitLabApiClient = class {
83
83
  };
84
84
 
85
85
  // src/client/merge-requests.ts
86
+ var SET_AUTO_MERGE_MUTATION = `
87
+ mutation setAutoMerge(
88
+ $projectPath: ID!
89
+ $iid: String!
90
+ $sha: String!
91
+ $strategy: MergeStrategyEnum
92
+ ) {
93
+ mergeRequestAccept(
94
+ input: {
95
+ projectPath: $projectPath
96
+ iid: $iid
97
+ sha: $sha
98
+ strategy: $strategy
99
+ }
100
+ ) {
101
+ mergeRequest {
102
+ id
103
+ iid
104
+ title
105
+ autoMergeEnabled
106
+ autoMergeStrategy
107
+ }
108
+ errors
109
+ }
110
+ }
111
+ `;
86
112
  var MergeRequestsClient = class extends GitLabApiClient {
87
113
  async getMergeRequest(projectId, mrIid, includeChanges) {
88
114
  const encodedProject = this.encodeProjectId(projectId);
@@ -222,6 +248,25 @@ var MergeRequestsClient = class extends GitLabApiClient {
222
248
  const path2 = `/projects/${encodedProject}/merge_requests/${mrIid}/diffs${query ? `?${query}` : ""}`;
223
249
  return this.fetch("GET", path2);
224
250
  }
251
+ /**
252
+ * Set auto-merge (MWPS) on a merge request using GraphQL API
253
+ * Uses the mergeRequestAccept mutation with a merge strategy
254
+ */
255
+ async setAutoMerge(projectId, mrIid, sha, strategy = "MERGE_WHEN_CHECKS_PASS") {
256
+ const result = await this.fetchGraphQL(SET_AUTO_MERGE_MUTATION, {
257
+ projectPath: projectId,
258
+ iid: String(mrIid),
259
+ sha,
260
+ strategy
261
+ });
262
+ if (result.mergeRequestAccept.errors.length > 0) {
263
+ throw new Error(`Failed to set auto-merge: ${result.mergeRequestAccept.errors.join(", ")}`);
264
+ }
265
+ if (!result.mergeRequestAccept.mergeRequest) {
266
+ throw new Error("Failed to set auto-merge: No merge request returned");
267
+ }
268
+ return result.mergeRequestAccept.mergeRequest;
269
+ }
225
270
  };
226
271
 
227
272
  // src/client/issues.ts
@@ -1775,6 +1820,33 @@ This is useful when you need to process diffs in chunks or when the MR has many
1775
1820
  });
1776
1821
  return JSON.stringify(diffs, null, 2);
1777
1822
  }
1823
+ }),
1824
+ gitlab_set_mr_auto_merge: tool({
1825
+ description: `Enable auto-merge (MWPS - Merge When Pipeline Succeeds) on a merge request.
1826
+ Uses the GitLab GraphQL API mergeRequestAccept mutation with a merge strategy.
1827
+ The MR will be automatically merged when all required conditions are met.
1828
+ Requires the MR to be approved and have a passing pipeline (depending on project settings).
1829
+ Note: You must provide the current HEAD SHA of the MR to prevent race conditions.`,
1830
+ args: {
1831
+ project_id: z.string().describe('The project ID or path (e.g., "gitlab-org/gitlab")'),
1832
+ mr_iid: z.number().describe("The internal ID of the merge request"),
1833
+ sha: z.string().describe(
1834
+ "The HEAD SHA of the merge request. Get this from the MR details (diff_refs.head_sha or sha field)."
1835
+ ),
1836
+ strategy: z.enum(["MERGE_WHEN_CHECKS_PASS", "ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS"]).optional().describe(
1837
+ "Auto-merge strategy. MERGE_WHEN_CHECKS_PASS (default) waits for all checks including approvals. ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS adds to merge train when checks pass."
1838
+ )
1839
+ },
1840
+ execute: async (args, _ctx) => {
1841
+ const client = getGitLabClient();
1842
+ const result = await client.setAutoMerge(
1843
+ args.project_id,
1844
+ args.mr_iid,
1845
+ args.sha,
1846
+ args.strategy || "MERGE_WHEN_CHECKS_PASS"
1847
+ );
1848
+ return JSON.stringify(result, null, 2);
1849
+ }
1778
1850
  })
1779
1851
  };
1780
1852
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/opencode-gitlab-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "GitLab tools plugin for OpenCode - provides GitLab API access for merge requests, issues, pipelines, and more",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",