opencode-gitlab-plugin 2.6.0 → 2.6.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 +8 -0
- package/dist/index.js +85 -64
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +86 -65
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +1 -1
package/dist/mcp-server.cjs
CHANGED
|
@@ -29105,7 +29105,7 @@ var RESOLVE_DISCUSSION_MUTATION = `
|
|
|
29105
29105
|
}
|
|
29106
29106
|
}
|
|
29107
29107
|
`;
|
|
29108
|
-
var MergeRequestsClient = class extends GitLabApiClient {
|
|
29108
|
+
var MergeRequestsClient = class _MergeRequestsClient extends GitLabApiClient {
|
|
29109
29109
|
async getMergeRequest(projectId, mrIid, includeChanges) {
|
|
29110
29110
|
const encodedProject = this.encodeProjectId(projectId);
|
|
29111
29111
|
let path2 = `/projects/${encodedProject}/merge_requests/${mrIid}`;
|
|
@@ -29327,20 +29327,48 @@ var MergeRequestsClient = class extends GitLabApiClient {
|
|
|
29327
29327
|
* Set auto-merge (MWPS) on a merge request using GraphQL API
|
|
29328
29328
|
* Uses the mergeRequestAccept mutation with a merge strategy
|
|
29329
29329
|
*/
|
|
29330
|
-
async setAutoMerge(projectId, mrIid, sha, strategy = "MERGE_WHEN_CHECKS_PASS") {
|
|
29331
|
-
|
|
29332
|
-
|
|
29333
|
-
|
|
29334
|
-
|
|
29335
|
-
|
|
29336
|
-
|
|
29337
|
-
|
|
29338
|
-
|
|
29339
|
-
|
|
29340
|
-
|
|
29341
|
-
|
|
29330
|
+
async setAutoMerge(projectId, mrIid, sha, strategy = "MERGE_WHEN_CHECKS_PASS", retries = 3) {
|
|
29331
|
+
let lastError = null;
|
|
29332
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
29333
|
+
const result = await this.fetchGraphQL(SET_AUTO_MERGE_MUTATION, {
|
|
29334
|
+
projectPath: projectId,
|
|
29335
|
+
iid: String(mrIid),
|
|
29336
|
+
sha,
|
|
29337
|
+
strategy
|
|
29338
|
+
});
|
|
29339
|
+
if (result.mergeRequestAccept.errors.length > 0) {
|
|
29340
|
+
const message = result.mergeRequestAccept.errors.join(", ");
|
|
29341
|
+
lastError = new Error(`Failed to set auto-merge: ${message}`);
|
|
29342
|
+
if (attempt < retries && _MergeRequestsClient.isTransientMergeError(message)) {
|
|
29343
|
+
await _MergeRequestsClient.delay(750 * (attempt + 1));
|
|
29344
|
+
continue;
|
|
29345
|
+
}
|
|
29346
|
+
throw lastError;
|
|
29347
|
+
}
|
|
29348
|
+
if (!result.mergeRequestAccept.mergeRequest) {
|
|
29349
|
+
lastError = new Error("Failed to set auto-merge: No merge request returned");
|
|
29350
|
+
if (attempt < retries) {
|
|
29351
|
+
await _MergeRequestsClient.delay(750 * (attempt + 1));
|
|
29352
|
+
continue;
|
|
29353
|
+
}
|
|
29354
|
+
throw lastError;
|
|
29355
|
+
}
|
|
29356
|
+
return result.mergeRequestAccept.mergeRequest;
|
|
29342
29357
|
}
|
|
29343
|
-
|
|
29358
|
+
throw lastError ?? new Error("Failed to set auto-merge: exhausted retries");
|
|
29359
|
+
}
|
|
29360
|
+
/**
|
|
29361
|
+
* True for GitLab merge errors that are transient because mergeability is
|
|
29362
|
+
* still being (re)computed. Such errors clear on their own within a second
|
|
29363
|
+
* or two, so callers should retry rather than treat them as real failures.
|
|
29364
|
+
*/
|
|
29365
|
+
static isTransientMergeError(message) {
|
|
29366
|
+
const m = message.toLowerCase();
|
|
29367
|
+
return m.includes("being checked") || m.includes("being recomputed") || m.includes("cannot be merged") || m.includes("not mergeable") || m.includes("merge failed") || m.includes("try again");
|
|
29368
|
+
}
|
|
29369
|
+
/** Small awaitable delay helper (ms). */
|
|
29370
|
+
static delay(ms) {
|
|
29371
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
29344
29372
|
}
|
|
29345
29373
|
/**
|
|
29346
29374
|
* Approve a merge request
|
|
@@ -29388,7 +29416,13 @@ var MergeRequestsClient = class extends GitLabApiClient {
|
|
|
29388
29416
|
* Returns detailed context about what happened
|
|
29389
29417
|
*/
|
|
29390
29418
|
async smartMerge(projectId, mrIid, sha, strategy = "MERGE_WHEN_CHECKS_PASS") {
|
|
29391
|
-
|
|
29419
|
+
let mr = await this.getMergeRequest(projectId, mrIid);
|
|
29420
|
+
if (mr.detailed_merge_status === "checking") {
|
|
29421
|
+
for (let attempt = 0; attempt < 5 && mr.detailed_merge_status === "checking"; attempt++) {
|
|
29422
|
+
await _MergeRequestsClient.delay(1e3 * (attempt + 1));
|
|
29423
|
+
mr = await this.getMergeRequest(projectId, mrIid);
|
|
29424
|
+
}
|
|
29425
|
+
}
|
|
29392
29426
|
const context = {
|
|
29393
29427
|
state: mr.state,
|
|
29394
29428
|
detailedMergeStatus: mr.detailed_merge_status,
|
|
@@ -29427,14 +29461,13 @@ var MergeRequestsClient = class extends GitLabApiClient {
|
|
|
29427
29461
|
};
|
|
29428
29462
|
}
|
|
29429
29463
|
}
|
|
29430
|
-
const autoMergeStatuses = ["ci_still_running", "not_approved"
|
|
29464
|
+
const autoMergeStatuses = ["ci_still_running", "not_approved"];
|
|
29431
29465
|
if (autoMergeStatuses.includes(mr.detailed_merge_status)) {
|
|
29432
29466
|
try {
|
|
29433
29467
|
const result = await this.setAutoMerge(projectId, mrIid, sha, strategy);
|
|
29434
29468
|
const autoMergeMessages = {
|
|
29435
29469
|
ci_still_running: "pipeline passes",
|
|
29436
|
-
not_approved: "approved"
|
|
29437
|
-
checking: "checks complete"
|
|
29470
|
+
not_approved: "approved"
|
|
29438
29471
|
};
|
|
29439
29472
|
return {
|
|
29440
29473
|
action: "auto_merge_enabled",
|
|
@@ -29793,22 +29826,8 @@ var GET_WORK_ITEM_NOTES_QUERY = `
|
|
|
29793
29826
|
}
|
|
29794
29827
|
`;
|
|
29795
29828
|
var CREATE_WORK_ITEM_MUTATION = `
|
|
29796
|
-
mutation createWorkItem(
|
|
29797
|
-
|
|
29798
|
-
$title: String!
|
|
29799
|
-
$workItemTypeId: WorkItemsTypeID!
|
|
29800
|
-
$description: String
|
|
29801
|
-
$labelIds: [LabelID!]
|
|
29802
|
-
$assigneeIds: [UserID!]
|
|
29803
|
-
) {
|
|
29804
|
-
workItemCreate(input: {
|
|
29805
|
-
projectPath: $projectPath
|
|
29806
|
-
title: $title
|
|
29807
|
-
workItemTypeId: $workItemTypeId
|
|
29808
|
-
descriptionWidget: { description: $description }
|
|
29809
|
-
labelsWidget: { labelIds: $labelIds }
|
|
29810
|
-
assigneesWidget: { assigneeIds: $assigneeIds }
|
|
29811
|
-
}) {
|
|
29829
|
+
mutation createWorkItem($input: WorkItemCreateInput!) {
|
|
29830
|
+
workItemCreate(input: $input) {
|
|
29812
29831
|
workItem {
|
|
29813
29832
|
${WORK_ITEM_FIELDS}
|
|
29814
29833
|
}
|
|
@@ -29817,22 +29836,8 @@ var CREATE_WORK_ITEM_MUTATION = `
|
|
|
29817
29836
|
}
|
|
29818
29837
|
`;
|
|
29819
29838
|
var UPDATE_WORK_ITEM_MUTATION = `
|
|
29820
|
-
mutation updateWorkItem(
|
|
29821
|
-
|
|
29822
|
-
$title: String
|
|
29823
|
-
$description: String
|
|
29824
|
-
$stateEvent: WorkItemStateEvent
|
|
29825
|
-
$labelIds: [LabelID!]
|
|
29826
|
-
$assigneeIds: [UserID!]
|
|
29827
|
-
) {
|
|
29828
|
-
workItemUpdate(input: {
|
|
29829
|
-
id: $id
|
|
29830
|
-
title: $title
|
|
29831
|
-
descriptionWidget: { description: $description }
|
|
29832
|
-
stateEvent: $stateEvent
|
|
29833
|
-
labelsWidget: { labelIds: $labelIds }
|
|
29834
|
-
assigneesWidget: { assigneeIds: $assigneeIds }
|
|
29835
|
-
}) {
|
|
29839
|
+
mutation updateWorkItem($input: WorkItemUpdateInput!) {
|
|
29840
|
+
workItemUpdate(input: $input) {
|
|
29836
29841
|
workItem {
|
|
29837
29842
|
${WORK_ITEM_FIELDS}
|
|
29838
29843
|
}
|
|
@@ -29926,14 +29931,21 @@ var WorkItemsClient = class extends GitLabApiClient {
|
|
|
29926
29931
|
async createWorkItem(projectId, options) {
|
|
29927
29932
|
const labelIds = options.labels?.map((l) => toGid("Label", l));
|
|
29928
29933
|
const assigneeIds = options.assignee_ids?.map((id) => toGid("User", id));
|
|
29929
|
-
const
|
|
29934
|
+
const input = {
|
|
29930
29935
|
projectPath: projectId,
|
|
29931
29936
|
title: options.title,
|
|
29932
|
-
workItemTypeId: toGid("WorkItems::Type", options.work_item_type_id)
|
|
29933
|
-
|
|
29934
|
-
|
|
29935
|
-
|
|
29936
|
-
}
|
|
29937
|
+
workItemTypeId: toGid("WorkItems::Type", options.work_item_type_id)
|
|
29938
|
+
};
|
|
29939
|
+
if (options.description !== void 0) {
|
|
29940
|
+
input.descriptionWidget = { description: options.description };
|
|
29941
|
+
}
|
|
29942
|
+
if (labelIds?.length) {
|
|
29943
|
+
input.labelsWidget = { labelIds };
|
|
29944
|
+
}
|
|
29945
|
+
if (assigneeIds?.length) {
|
|
29946
|
+
input.assigneesWidget = { assigneeIds };
|
|
29947
|
+
}
|
|
29948
|
+
const result = await this.fetchGraphQL(CREATE_WORK_ITEM_MUTATION, { input });
|
|
29937
29949
|
if (result.workItemCreate.errors.length > 0) {
|
|
29938
29950
|
throw new Error(`Failed to create work item: ${result.workItemCreate.errors.join(", ")}`);
|
|
29939
29951
|
}
|
|
@@ -29951,14 +29963,23 @@ var WorkItemsClient = class extends GitLabApiClient {
|
|
|
29951
29963
|
const stateEvent = options.state_event ? options.state_event === "close" ? "CLOSE" : "REOPEN" : void 0;
|
|
29952
29964
|
const labelIds = options.labels?.map((l) => toGid("Label", l));
|
|
29953
29965
|
const assigneeIds = options.assignee_ids?.map((id) => toGid("User", id));
|
|
29954
|
-
const
|
|
29955
|
-
|
|
29956
|
-
title
|
|
29957
|
-
|
|
29958
|
-
|
|
29959
|
-
|
|
29960
|
-
|
|
29961
|
-
|
|
29966
|
+
const input = { id: gid };
|
|
29967
|
+
if (options.title !== void 0) {
|
|
29968
|
+
input.title = options.title;
|
|
29969
|
+
}
|
|
29970
|
+
if (options.description !== void 0) {
|
|
29971
|
+
input.descriptionWidget = { description: options.description };
|
|
29972
|
+
}
|
|
29973
|
+
if (stateEvent !== void 0) {
|
|
29974
|
+
input.stateEvent = stateEvent;
|
|
29975
|
+
}
|
|
29976
|
+
if (labelIds?.length) {
|
|
29977
|
+
input.labelsWidget = { addLabelIds: labelIds };
|
|
29978
|
+
}
|
|
29979
|
+
if (assigneeIds?.length) {
|
|
29980
|
+
input.assigneesWidget = { assigneeIds };
|
|
29981
|
+
}
|
|
29982
|
+
const result = await this.fetchGraphQL(UPDATE_WORK_ITEM_MUTATION, { input });
|
|
29962
29983
|
if (result.workItemUpdate.errors.length > 0) {
|
|
29963
29984
|
throw new Error(`Failed to update work item: ${result.workItemUpdate.errors.join(", ")}`);
|
|
29964
29985
|
}
|
|
@@ -34075,7 +34096,7 @@ async function main() {
|
|
|
34075
34096
|
...auditTools,
|
|
34076
34097
|
...awardEmojiTools
|
|
34077
34098
|
};
|
|
34078
|
-
const version2 = true ? "2.6.
|
|
34099
|
+
const version2 = true ? "2.6.1" : "0.0.0";
|
|
34079
34100
|
const server = new McpServer({ name: "gitlab", version: version2 });
|
|
34080
34101
|
adaptToolsToMcp(server, allTools);
|
|
34081
34102
|
const transport = new StdioServerTransport();
|