opencode-gitlab-plugin 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +52 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +53 -12
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +1 -1
package/dist/mcp-server.cjs
CHANGED
|
@@ -29469,11 +29469,48 @@ var MergeRequestsClient = class _MergeRequestsClient extends GitLabApiClient {
|
|
|
29469
29469
|
Object.keys(body).length > 0 ? body : void 0
|
|
29470
29470
|
);
|
|
29471
29471
|
}
|
|
29472
|
+
/**
|
|
29473
|
+
* Resolve the auto-merge strategy for a project.
|
|
29474
|
+
*
|
|
29475
|
+
* When the caller does not specify a strategy, projects with merge trains
|
|
29476
|
+
* enabled require ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS; otherwise
|
|
29477
|
+
* MERGE_WHEN_CHECKS_PASS is correct. Using the wrong one causes auto-merge to
|
|
29478
|
+
* fail with an opaque "The merge failed" error. Falls back to
|
|
29479
|
+
* MERGE_WHEN_CHECKS_PASS if the project setting cannot be read.
|
|
29480
|
+
*
|
|
29481
|
+
* Returns both the chosen strategy and how it was arrived at, so the caller
|
|
29482
|
+
* can thread a breadcrumb into its result. A bare fallback would collapse a
|
|
29483
|
+
* 401, a network timeout, and a genuine 404 all into a silent MWPS default,
|
|
29484
|
+
* reintroducing the opaque "The merge failed" this behaviour exists to
|
|
29485
|
+
* eliminate; `detection` makes that observable without changing the fallback.
|
|
29486
|
+
*/
|
|
29487
|
+
async resolveAutoMergeStrategy(projectId) {
|
|
29488
|
+
try {
|
|
29489
|
+
const encodedProject = this.encodeProjectId(projectId);
|
|
29490
|
+
const project = await this.fetch(
|
|
29491
|
+
"GET",
|
|
29492
|
+
`/projects/${encodedProject}`
|
|
29493
|
+
);
|
|
29494
|
+
return project.merge_trains_enabled ? {
|
|
29495
|
+
strategy: "ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS",
|
|
29496
|
+
detection: "merge_trains_enabled"
|
|
29497
|
+
} : { strategy: "MERGE_WHEN_CHECKS_PASS", detection: "merge_trains_disabled" };
|
|
29498
|
+
} catch (error45) {
|
|
29499
|
+
return {
|
|
29500
|
+
strategy: "MERGE_WHEN_CHECKS_PASS",
|
|
29501
|
+
detection: "defaulted_after_error",
|
|
29502
|
+
reason: error45 instanceof Error ? error45.message : String(error45)
|
|
29503
|
+
};
|
|
29504
|
+
}
|
|
29505
|
+
}
|
|
29472
29506
|
/**
|
|
29473
29507
|
* Smart merge: merge immediately if checks pass, otherwise set auto-merge
|
|
29474
|
-
* Returns detailed context about what happened
|
|
29508
|
+
* Returns detailed context about what happened.
|
|
29509
|
+
*
|
|
29510
|
+
* If `strategy` is omitted, it is auto-detected from the project's merge
|
|
29511
|
+
* train settings (merge-train projects need ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS).
|
|
29475
29512
|
*/
|
|
29476
|
-
async smartMerge(projectId, mrIid, sha, strategy
|
|
29513
|
+
async smartMerge(projectId, mrIid, sha, strategy) {
|
|
29477
29514
|
let mr = await this.getMergeRequest(projectId, mrIid);
|
|
29478
29515
|
if (mr.detailed_merge_status === "checking") {
|
|
29479
29516
|
for (let attempt = 0; attempt < 5 && mr.detailed_merge_status === "checking"; attempt++) {
|
|
@@ -29521,15 +29558,24 @@ var MergeRequestsClient = class _MergeRequestsClient extends GitLabApiClient {
|
|
|
29521
29558
|
}
|
|
29522
29559
|
const autoMergeStatuses = ["ci_still_running", "not_approved"];
|
|
29523
29560
|
if (autoMergeStatuses.includes(mr.detailed_merge_status)) {
|
|
29561
|
+
let resolvedStrategy;
|
|
29562
|
+
if (strategy) {
|
|
29563
|
+
resolvedStrategy = strategy;
|
|
29564
|
+
context.strategyDetection = `explicit: ${strategy}`;
|
|
29565
|
+
} else {
|
|
29566
|
+
const detected = await this.resolveAutoMergeStrategy(projectId);
|
|
29567
|
+
resolvedStrategy = detected.strategy;
|
|
29568
|
+
context.strategyDetection = detected.detection === "defaulted_after_error" ? `failed, defaulted to MERGE_WHEN_CHECKS_PASS${detected.reason ? ` (${detected.reason})` : ""}` : `auto-detected (${detected.detection}): ${detected.strategy}`;
|
|
29569
|
+
}
|
|
29524
29570
|
try {
|
|
29525
|
-
const result = await this.setAutoMerge(projectId, mrIid, sha,
|
|
29571
|
+
const result = await this.setAutoMerge(projectId, mrIid, sha, resolvedStrategy);
|
|
29526
29572
|
const autoMergeMessages = {
|
|
29527
29573
|
ci_still_running: "pipeline passes",
|
|
29528
29574
|
not_approved: "approved"
|
|
29529
29575
|
};
|
|
29530
29576
|
return {
|
|
29531
29577
|
action: "auto_merge_enabled",
|
|
29532
|
-
message: `Auto-merge enabled (${
|
|
29578
|
+
message: `Auto-merge enabled (${resolvedStrategy}). MR will merge when ${autoMergeMessages[mr.detailed_merge_status]}.`,
|
|
29533
29579
|
mergeRequest: result,
|
|
29534
29580
|
context
|
|
29535
29581
|
};
|
|
@@ -31779,17 +31825,12 @@ Note: You must provide the current HEAD SHA of the MR to prevent race conditions
|
|
|
31779
31825
|
"The HEAD SHA of the merge request. Get this from the MR details (diff_refs.head_sha or sha field)."
|
|
31780
31826
|
),
|
|
31781
31827
|
strategy: z.enum(["MERGE_WHEN_CHECKS_PASS", "ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS"]).optional().describe(
|
|
31782
|
-
"Auto-merge strategy when immediate merge is not possible.
|
|
31828
|
+
"Auto-merge strategy when immediate merge is not possible. If omitted, it is auto-detected from the project: merge-train projects use ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS, otherwise MERGE_WHEN_CHECKS_PASS."
|
|
31783
31829
|
)
|
|
31784
31830
|
},
|
|
31785
31831
|
execute: async (args, _ctx) => {
|
|
31786
31832
|
const client = getGitLabClient();
|
|
31787
|
-
const result = await client.smartMerge(
|
|
31788
|
-
args.project_id,
|
|
31789
|
-
args.mr_iid,
|
|
31790
|
-
args.sha,
|
|
31791
|
-
args.strategy || "MERGE_WHEN_CHECKS_PASS"
|
|
31792
|
-
);
|
|
31833
|
+
const result = await client.smartMerge(args.project_id, args.mr_iid, args.sha, args.strategy);
|
|
31793
31834
|
return JSON.stringify(result, null, 2);
|
|
31794
31835
|
}
|
|
31795
31836
|
}),
|
|
@@ -34181,7 +34222,7 @@ async function main() {
|
|
|
34181
34222
|
...auditTools,
|
|
34182
34223
|
...awardEmojiTools
|
|
34183
34224
|
};
|
|
34184
|
-
const version2 = true ? "2.8.
|
|
34225
|
+
const version2 = true ? "2.8.1" : "0.0.0";
|
|
34185
34226
|
const server = new McpServer({ name: "gitlab", version: version2 });
|
|
34186
34227
|
adaptToolsToMcp(server, allTools);
|
|
34187
34228
|
const transport = new StdioServerTransport();
|