opencode-gitlab-plugin 2.7.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 +14 -0
- package/README.md +2 -2
- package/dist/index.js +58 -13
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +59 -14
- 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
|
};
|
|
@@ -31600,7 +31646,10 @@ Returns the created merge request with all details.`,
|
|
|
31600
31646
|
milestone_id: z.number().optional().describe("The ID of a milestone"),
|
|
31601
31647
|
remove_source_branch: z.boolean().optional().describe("Remove source branch after merge (default: false)"),
|
|
31602
31648
|
squash: z.boolean().optional().describe("Squash commits on merge (default: false)"),
|
|
31603
|
-
allow_collaboration: z.boolean().optional().describe("Allow commits from members who can merge to the target branch")
|
|
31649
|
+
allow_collaboration: z.boolean().optional().describe("Allow commits from members who can merge to the target branch"),
|
|
31650
|
+
target_project_id: z.number().optional().describe(
|
|
31651
|
+
"The ID of the target project for cross-project (fork to upstream) merge requests. Defaults to the source project when omitted."
|
|
31652
|
+
)
|
|
31604
31653
|
},
|
|
31605
31654
|
execute: async (args, _ctx) => {
|
|
31606
31655
|
const client = getGitLabClient();
|
|
@@ -31615,7 +31664,8 @@ Returns the created merge request with all details.`,
|
|
|
31615
31664
|
milestone_id: args.milestone_id,
|
|
31616
31665
|
remove_source_branch: args.remove_source_branch,
|
|
31617
31666
|
squash: args.squash,
|
|
31618
|
-
allow_collaboration: args.allow_collaboration
|
|
31667
|
+
allow_collaboration: args.allow_collaboration,
|
|
31668
|
+
target_project_id: args.target_project_id
|
|
31619
31669
|
});
|
|
31620
31670
|
return JSON.stringify(mr, null, 2);
|
|
31621
31671
|
}
|
|
@@ -31775,17 +31825,12 @@ Note: You must provide the current HEAD SHA of the MR to prevent race conditions
|
|
|
31775
31825
|
"The HEAD SHA of the merge request. Get this from the MR details (diff_refs.head_sha or sha field)."
|
|
31776
31826
|
),
|
|
31777
31827
|
strategy: z.enum(["MERGE_WHEN_CHECKS_PASS", "ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS"]).optional().describe(
|
|
31778
|
-
"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."
|
|
31779
31829
|
)
|
|
31780
31830
|
},
|
|
31781
31831
|
execute: async (args, _ctx) => {
|
|
31782
31832
|
const client = getGitLabClient();
|
|
31783
|
-
const result = await client.smartMerge(
|
|
31784
|
-
args.project_id,
|
|
31785
|
-
args.mr_iid,
|
|
31786
|
-
args.sha,
|
|
31787
|
-
args.strategy || "MERGE_WHEN_CHECKS_PASS"
|
|
31788
|
-
);
|
|
31833
|
+
const result = await client.smartMerge(args.project_id, args.mr_iid, args.sha, args.strategy);
|
|
31789
31834
|
return JSON.stringify(result, null, 2);
|
|
31790
31835
|
}
|
|
31791
31836
|
}),
|
|
@@ -34177,7 +34222,7 @@ async function main() {
|
|
|
34177
34222
|
...auditTools,
|
|
34178
34223
|
...awardEmojiTools
|
|
34179
34224
|
};
|
|
34180
|
-
const version2 = true ? "2.
|
|
34225
|
+
const version2 = true ? "2.8.1" : "0.0.0";
|
|
34181
34226
|
const server = new McpServer({ name: "gitlab", version: version2 });
|
|
34182
34227
|
adaptToolsToMcp(server, allTools);
|
|
34183
34228
|
const transport = new StdioServerTransport();
|