@gitlab/opencode-gitlab-plugin 1.5.1 → 1.5.3

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,26 @@
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.5.3](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/compare/v1.5.2...v1.5.3) (2026-02-03)
6
+
7
+
8
+ ### 🐛 Bug Fixes
9
+
10
+ * use null checks for stricter validation ([6c39c81](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/commit/6c39c81aa839a99a0c12b3aa57d9376e5e3788d4))
11
+
12
+
13
+ ### ♻️ Code Refactoring
14
+
15
+ * consolidate discussion tools into unified interface ([aa0cefd](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/commit/aa0cefdcc36fbd00c375ca17b0d75dbda3ecbe18))
16
+ * remove gitlab_create_commit tool ([4c4944d](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/commit/4c4944d8afcd710e7b0910d82197802eee75e6fd))
17
+
18
+ ## [1.5.2](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/compare/v1.5.1...v1.5.2) (2026-02-02)
19
+
20
+
21
+ ### 📚 Documentation
22
+
23
+ * update documentation to reflect GraphQL API migrations ([1b5aff1](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/commit/1b5aff1d630577d9ec05966e249a89fdb8a86b3f))
24
+
5
25
  ## [1.5.1](https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/compare/v1.5.0...v1.5.1) (2026-02-02)
6
26
 
7
27
 
@@ -203,65 +223,6 @@ All notable changes to this project will be documented in this file. See [Conven
203
223
 
204
224
  * create release ([e74f8a7](https://gitlab.com/vglafirov/opencode-gitlab-plugin/commit/e74f8a7550a6d2a58b3fb551fe4ad3a2db56e0c7))
205
225
 
206
- ## [Unreleased]
207
-
208
- ### Added
209
- - **GraphQL API Support** - Added `fetchGraphQL()` method to base `GitLabApiClient` class
210
- - Enables GraphQL queries and mutations with proper error handling
211
- - Supports variables and returns typed responses
212
- - Foundation for advanced GitLab features
213
- - Enhanced JSDoc documentation with `@template` parameter
214
- - **Vulnerability Management Tools** - 6 new GraphQL-based security tools:
215
- - `gitlab_create_vulnerability_issue` - Create issue linked to vulnerabilities
216
- - `gitlab_dismiss_vulnerability` - Dismiss vulnerability with reason (ACCEPTABLE_RISK, FALSE_POSITIVE, etc.)
217
- - `gitlab_confirm_vulnerability` - Confirm a security vulnerability
218
- - `gitlab_revert_vulnerability_to_detected` - Revert vulnerability state back to detected
219
- - `gitlab_update_vulnerability_severity` - Update vulnerability severity level (CRITICAL, HIGH, MEDIUM, LOW, INFO, UNKNOWN)
220
- - `gitlab_link_vulnerability_to_issue` - Link existing issue to vulnerabilities
221
- - All tools require Developer role or higher
222
- - Comprehensive test coverage with 29 new tests (22 security + 7 validation)
223
- - **GID Validation Utilities** - New validation module for GitLab Global IDs
224
- - `isValidGid()` - Validates GID format with optional type checking
225
- - `validateGid()` - Validates and throws descriptive errors for invalid GIDs
226
- - Integrated into all security methods that accept GIDs
227
- - Provides better error messages for incorrect GID formats
228
-
229
- ### Changed
230
- - **Refactored Security Client** - Improved code maintainability
231
- - Extracted all GraphQL mutation queries to constants
232
- - Makes queries easier to update and maintain
233
- - Improved code readability in security methods
234
- - **Enhanced Type Safety** - Added validation for all GID parameters
235
- - Validates vulnerability IDs format: `gid://gitlab/Vulnerability/{id}`
236
- - Validates issue IDs format: `gid://gitlab/Issue/{id}`
237
- - Prevents invalid GID formats from reaching GitLab API
238
- - **Audit Events API** - 3 new tools for security and compliance monitoring:
239
- - `gitlab_list_project_audit_events` - List audit events for a project (requires owner role)
240
- - `gitlab_list_group_audit_events` - List audit events for a group (requires owner role)
241
- - `gitlab_list_instance_audit_events` - List instance-level audit events (requires admin)
242
- - Support for filtering by date range, entity type, entity ID, and author ID with pagination
243
- - **Paginated MR Diffs** - `gitlab_list_merge_request_diffs` tool for handling large changesets
244
- - Fetch merge request diffs with pagination support
245
- - Useful for processing diffs in chunks when MRs have many changed files
246
- - **Single Note Retrieval** - 3 new tools for granular comment access:
247
- - `gitlab_get_epic_note` - Get a single note from an epic by ID
248
- - `gitlab_get_issue_note` - Get a single note from an issue by ID
249
- - `gitlab_get_commit_comments` - Get all comments on a specific commit
250
- - Retrieve specific comments without fetching all notes
251
- - **`gitlab_create_issue`** tool - Create new issues in GitLab projects with full support for:
252
- - Required parameters: `project_id`, `title`
253
- - Optional parameters: `description`, `assignee_ids`, `milestone_id`, `labels`, `due_date`, `confidential`, `weight`, `epic_id`, `issue_type`
254
- - Support for different issue types: `issue`, `incident`, `test_case`, `task`
255
- - Comprehensive test coverage for client and tool
256
- - Detailed documentation in `docs/CREATE_ISSUE_TOOL.md`
257
-
258
- ### Changed
259
- - Updated README.md with `gitlab_create_issue` tool documentation
260
- - Added usage example for creating and managing issues
261
- - Updated tool count from 60+ to 68+ tools (7 new tools added)
262
- - Updated index.ts comment to reflect new audit, paginated diffs, and single note retrieval capabilities
263
- - Integrated `AuditClient` into `UnifiedGitLabClient` via mixins
264
-
265
226
  ## [1.6.3](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v1.6.2...v1.6.3) (2025-12-14)
266
227
 
267
228
 
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![npm version](https://img.shields.io/npm/v/@gitlab/opencode-gitlab-plugin.svg)](https://www.npmjs.com/package/@gitlab/opencode-gitlab-plugin)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- A comprehensive GitLab API plugin for OpenCode that provides AI-powered access to GitLab's REST API. This plugin enables seamless interaction with merge requests, issues, pipelines, repositories, epics, snippets, audit events, and more through natural language commands.
7
+ A comprehensive GitLab API plugin for OpenCode that provides AI-powered access to GitLab's REST and GraphQL APIs. This plugin enables seamless interaction with merge requests, issues, pipelines, repositories, epics, snippets, audit events, and more through natural language commands.
8
8
 
9
9
  ## 📋 Table of Contents
10
10
 
@@ -45,14 +45,27 @@ A comprehensive GitLab API plugin for OpenCode that provides AI-powered access t
45
45
  - **TypeScript**: Full type safety with comprehensive type definitions
46
46
  - **ESM Support**: Modern ES modules for optimal tree-shaking
47
47
  - **Zod Validation**: Runtime schema validation for all API inputs
48
- - **GraphQL Support**: Native GraphQL API support with type-safe mutations and queries
48
+ - **GraphQL Support**: Native GraphQL API support with type-safe mutations and queries for TODOs, Notes, Discussions, Auto-merge, and Security tools
49
+ - **Cursor-Based Pagination**: GraphQL-powered pagination with `first`/`after` and `last`/`before` cursors for efficient data fetching
49
50
  - **GID Validation**: Automatic validation of GitLab Global IDs with descriptive error messages
50
51
  - **Error Handling**: Robust error handling with detailed error messages
51
52
  - **Authentication**: Multiple authentication methods (OAuth, API tokens)
52
53
  - **Rate Limiting**: Built-in handling for GitLab API rate limits
53
54
  - **Caching**: Efficient API response handling
54
55
  - **Modular Architecture**: Clean separation of concerns with client and tool modules
55
- - **Comprehensive Testing**: 142 tests with full coverage of all features
56
+ - **Comprehensive Testing**: 181 tests with full coverage of all features
57
+
58
+ ### GraphQL-Powered Tools
59
+
60
+ The following tools use GitLab's GraphQL API for enhanced functionality:
61
+
62
+ | Category | Tools | Benefits |
63
+ | --------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
64
+ | **TODOs** | `gitlab_list_todos`, `gitlab_get_todo_count` | Cursor-based pagination, rich filtering |
65
+ | **Notes** | `gitlab_list_mr_notes`, `gitlab_list_issue_notes`, `gitlab_list_epic_notes`, `gitlab_list_snippet_notes` | Efficient pagination, consistent response format |
66
+ | **Discussions** | `gitlab_list_mr_discussions`, `gitlab_list_issue_discussions`, `gitlab_list_epic_discussions`, `gitlab_list_snippet_discussions` | Cursor-based pagination, nested note support |
67
+ | **Auto-merge** | `gitlab_set_mr_auto_merge` | MWPS (Merge When Pipeline Succeeds), merge train support |
68
+ | **Security** | All vulnerability management tools | Type-safe GID validation, mutation support |
56
69
 
57
70
  ## 🏗️ Architecture
58
71
 
@@ -74,6 +87,7 @@ graph TB
74
87
 
75
88
  subgraph "GitLab API"
76
89
  REST[REST API v4]
90
+ GraphQL[GraphQL API]
77
91
  MR[Merge Requests]
78
92
  Issues[Issues]
79
93
  Pipelines[Pipelines]
@@ -88,12 +102,14 @@ graph TB
88
102
  Validator --> Client
89
103
  Client --> Auth
90
104
  Auth --> REST
105
+ Auth --> GraphQL
91
106
  REST --> MR
92
107
  REST --> Issues
93
108
  REST --> Pipelines
94
109
  REST --> Repos
95
110
  REST --> Epics
96
- REST --> Security
111
+ GraphQL --> Security
112
+ GraphQL --> MR
97
113
  ```
98
114
 
99
115
  ### Plugin Structure
@@ -271,9 +287,9 @@ Or for API tokens:
271
287
 
272
288
  ## 🛠️ Available Tools
273
289
 
274
- The plugin provides **104 tools** organized into the following categories:
290
+ The plugin provides **102 tools** organized into the following categories:
275
291
 
276
- ### Merge Request Tools (15 tools)
292
+ ### Merge Request Tools (16 tools)
277
293
 
278
294
  | Tool | Description |
279
295
  | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
@@ -282,9 +298,9 @@ The plugin provides **104 tools** organized into the following categories:
282
298
  | `gitlab_create_merge_request` | Create a new merge request |
283
299
  | `gitlab_update_merge_request` | Update merge request title, description, state, assignees, reviewers, and labels |
284
300
  | `gitlab_get_mr_changes` | Get file changes/diffs for a merge request |
285
- | `gitlab_list_mr_discussions` | List discussion threads on a merge request with nested notes |
301
+ | `gitlab_list_mr_discussions` | List discussion threads on a merge request (GraphQL with cursor-based pagination) |
286
302
  | `gitlab_get_mr_discussion` | Get a specific discussion thread with all replies |
287
- | `gitlab_list_mr_notes` | List all comments in flat structure (easier than nested discussions) |
303
+ | `gitlab_list_mr_notes` | List all comments with cursor-based pagination (GraphQL) |
288
304
  | `gitlab_create_mr_note` | Add a comment or reply to a merge request discussion |
289
305
  | `gitlab_create_mr_discussion` | Start a new discussion thread (optionally on specific code lines) |
290
306
  | `gitlab_resolve_mr_discussion` | Mark a discussion as resolved after addressing feedback |
@@ -292,6 +308,7 @@ The plugin provides **104 tools** organized into the following categories:
292
308
  | `gitlab_get_mr_commits` | Get all commits in a merge request |
293
309
  | `gitlab_get_mr_pipelines` | Get all pipelines for a merge request |
294
310
  | `gitlab_list_merge_request_diffs` | List file diffs with pagination support for large changesets |
311
+ | `gitlab_set_mr_auto_merge` | Enable auto-merge (MWPS) using GraphQL API when pipeline succeeds |
295
312
 
296
313
  ### Issue Tools (10 tools)
297
314
 
@@ -300,8 +317,8 @@ The plugin provides **104 tools** organized into the following categories:
300
317
  | `gitlab_create_issue` | Create a new issue with title, description, labels, assignees, and milestone |
301
318
  | `gitlab_get_issue` | Get issue details including state, author, assignees, labels, and comments |
302
319
  | `gitlab_list_issues` | List issues with filtering by state, labels, assignee, and milestone |
303
- | `gitlab_list_issue_notes` | List all comments including system notes |
304
- | `gitlab_list_issue_discussions` | List discussion threads with nested notes |
320
+ | `gitlab_list_issue_notes` | List all comments with cursor-based pagination (GraphQL) |
321
+ | `gitlab_list_issue_discussions` | List discussion threads with cursor-based pagination (GraphQL) |
305
322
  | `gitlab_get_issue_discussion` | Get a specific discussion thread with context |
306
323
  | `gitlab_create_issue_note` | Add a comment or reply to an issue discussion |
307
324
  | `gitlab_get_issue_note` | Get a specific note by ID with full details |
@@ -319,8 +336,8 @@ The plugin provides **104 tools** organized into the following categories:
319
336
  | `gitlab_list_epic_issues` | Get all issues linked to an epic |
320
337
  | `gitlab_add_issue_to_epic` | Link an issue to an epic |
321
338
  | `gitlab_remove_issue_from_epic` | Unlink an issue from an epic |
322
- | `gitlab_list_epic_notes` | List all comments on an epic |
323
- | `gitlab_list_epic_discussions` | List discussion threads on an epic |
339
+ | `gitlab_list_epic_notes` | List all comments with cursor-based pagination (GraphQL) |
340
+ | `gitlab_list_epic_discussions` | List discussion threads with cursor-based pagination (GraphQL) |
324
341
  | `gitlab_create_epic_note` | Add a comment or reply to an epic discussion |
325
342
  | `gitlab_get_epic_discussion` | Get a specific epic discussion thread |
326
343
  | `gitlab_get_epic_note` | Get a specific epic note by ID |
@@ -338,7 +355,7 @@ The plugin provides **104 tools** organized into the following categories:
338
355
  | `gitlab_lint_ci_config` | Validate CI/CD YAML configuration with project context |
339
356
  | `gitlab_lint_existing_ci_config` | Validate existing .gitlab-ci.yml from repository |
340
357
 
341
- ### Repository Tools (16 tools)
358
+ ### Repository Tools (12 tools)
342
359
 
343
360
  | Tool | Description |
344
361
  | --------------------------------- | ---------------------------------------------------------------------------- |
@@ -399,12 +416,12 @@ The plugin provides **104 tools** organized into the following categories:
399
416
 
400
417
  ### TODO Tools (4 tools)
401
418
 
402
- | Tool | Description |
403
- | ---------------------------- | ----------------------------------------------- |
404
- | `gitlab_list_todos` | List TODO items for current user with filtering |
405
- | `gitlab_mark_todo_done` | Mark a specific TODO as completed |
406
- | `gitlab_mark_all_todos_done` | Mark all pending TODOs as completed |
407
- | `gitlab_get_todo_count` | Get count of pending TODOs |
419
+ | Tool | Description |
420
+ | ---------------------------- | ------------------------------------------------------ |
421
+ | `gitlab_list_todos` | List TODO items with cursor-based pagination (GraphQL) |
422
+ | `gitlab_mark_todo_done` | Mark a specific TODO as completed |
423
+ | `gitlab_mark_all_todos_done` | Mark all pending TODOs as completed |
424
+ | `gitlab_get_todo_count` | Get count of pending TODOs (GraphQL) |
408
425
 
409
426
  ### Project & User Tools (3 tools)
410
427
 
@@ -416,13 +433,13 @@ The plugin provides **104 tools** organized into the following categories:
416
433
 
417
434
  ### Snippet Tools (5 tools)
418
435
 
419
- | Tool | Description |
420
- | ---------------------------------- | ---------------------------------------------- |
421
- | `gitlab_list_snippet_discussions` | List discussion threads on a snippet |
422
- | `gitlab_get_snippet_discussion` | Get a specific snippet discussion thread |
423
- | `gitlab_list_snippet_notes` | List all comments on a snippet |
424
- | `gitlab_create_snippet_note` | Add a comment or reply to a snippet discussion |
425
- | `gitlab_create_snippet_discussion` | Start a new discussion on a snippet |
436
+ | Tool | Description |
437
+ | ---------------------------------- | -------------------------------------------------------------- |
438
+ | `gitlab_list_snippet_discussions` | List discussion threads with cursor-based pagination (GraphQL) |
439
+ | `gitlab_get_snippet_discussion` | Get a specific snippet discussion thread |
440
+ | `gitlab_list_snippet_notes` | List all comments with cursor-based pagination (GraphQL) |
441
+ | `gitlab_create_snippet_note` | Add a comment or reply to a snippet discussion |
442
+ | `gitlab_create_snippet_discussion` | Start a new discussion on a snippet |
426
443
 
427
444
  ### Discussion Tools (2 tools)
428
445
 
@@ -604,22 +621,32 @@ const fileContent = await plugin.tool.gitlab_get_file.execute({
604
621
  });
605
622
  ```
606
623
 
607
- ### Example 6: Manage TODOs
624
+ ### Example 6: Manage TODOs (GraphQL with Pagination)
608
625
 
609
626
  ```javascript
610
- // Get TODO count
627
+ // Get TODO count (uses GraphQL)
611
628
  const todoCount = await plugin.tool.gitlab_get_todo_count.execute({});
612
629
 
613
- // List pending TODOs
614
- const todos = await plugin.tool.gitlab_list_todos.execute({
630
+ // List pending TODOs with cursor-based pagination
631
+ const firstPage = await plugin.tool.gitlab_list_todos.execute({
615
632
  state: 'pending',
616
633
  type: 'MergeRequest',
617
- limit: 20,
634
+ first: 20,
618
635
  });
619
636
 
637
+ // Get next page using cursor
638
+ if (firstPage.todos.pageInfo.hasNextPage) {
639
+ const nextPage = await plugin.tool.gitlab_list_todos.execute({
640
+ state: 'pending',
641
+ type: 'MergeRequest',
642
+ first: 20,
643
+ after: firstPage.todos.pageInfo.endCursor,
644
+ });
645
+ }
646
+
620
647
  // Mark specific TODO as done
621
648
  await plugin.tool.gitlab_mark_todo_done.execute({
622
- todo_id: todos[0].id,
649
+ todo_id: firstPage.todos.nodes[0].id,
623
650
  });
624
651
 
625
652
  // Mark all TODOs as done
@@ -655,7 +682,27 @@ const commit = await plugin.tool.gitlab_create_commit.execute({
655
682
  });
656
683
  ```
657
684
 
658
- ### Example 8: Manage Security Vulnerabilities
685
+ ### Example 8: Enable Auto-Merge (MWPS)
686
+
687
+ ```javascript
688
+ // Get merge request to retrieve current HEAD SHA
689
+ const mr = await plugin.tool.gitlab_get_merge_request.execute({
690
+ project_id: 'my-group/my-project',
691
+ mr_iid: 123,
692
+ });
693
+
694
+ // Enable auto-merge when pipeline succeeds (GraphQL)
695
+ const result = await plugin.tool.gitlab_set_mr_auto_merge.execute({
696
+ project_id: 'my-group/my-project',
697
+ mr_iid: 123,
698
+ sha: mr.sha, // Required to prevent race conditions
699
+ strategy: 'MERGE_WHEN_CHECKS_PASS', // or 'ADD_TO_MERGE_TRAIN_WHEN_CHECKS_PASS'
700
+ });
701
+
702
+ console.log(`Auto-merge enabled: ${result.mergeRequest.autoMergeEnabled}`);
703
+ ```
704
+
705
+ ### Example 9: Manage Security Vulnerabilities
659
706
 
660
707
  ```javascript
661
708
  // List vulnerabilities in a project
@@ -853,11 +900,11 @@ npm run test:coverage
853
900
 
854
901
  **Test Coverage:**
855
902
 
856
- - **142 tests** across 18 test files
857
- - Client tests for all API methods
903
+ - **181 tests** across 21 test files
904
+ - Client tests for all API methods (REST and GraphQL)
858
905
  - Tool tests for all tool definitions
859
906
  - Validation tests for GID utilities
860
- - GraphQL method tests
907
+ - GraphQL method tests for Notes, Discussions, TODOs
861
908
  - All tests passing ✅
862
909
 
863
910
  ## 🚀 CI/CD Pipeline
@@ -993,7 +1040,8 @@ async fetchGraphQL<T>(query: string, variables?: Record<string, unknown>): Promi
993
1040
  - Full TypeScript type safety with generic return types
994
1041
  - Automatic error handling for both HTTP and GraphQL errors
995
1042
  - Support for query variables
996
- - Used by all GraphQL-based security tools
1043
+ - Cursor-based pagination support for large result sets
1044
+ - Used by TODOs, Notes, Discussions, Auto-merge, and Security tools
997
1045
 
998
1046
  **Example:**
999
1047
 
@@ -1009,6 +1057,18 @@ const result = await client.fetchGraphQL<{ vulnerability: { id: string } }>(
1009
1057
  );
1010
1058
  ```
1011
1059
 
1060
+ **Pagination Example:**
1061
+
1062
+ ```typescript
1063
+ // First page
1064
+ const page1 = await plugin.tool.gitlab_list_todos.execute({ first: 20 });
1065
+ // Navigate with cursor
1066
+ const page2 = await plugin.tool.gitlab_list_todos.execute({
1067
+ first: 20,
1068
+ after: page1.todos.pageInfo.endCursor,
1069
+ });
1070
+ ```
1071
+
1012
1072
  #### Project ID Encoding
1013
1073
 
1014
1074
  ```typescript
package/dist/index.d.ts CHANGED
@@ -4,9 +4,9 @@ import { Plugin } from '@opencode-ai/plugin';
4
4
  * GitLab Tools Plugin for OpenCode
5
5
  *
6
6
  * Provides tools for interacting with GitLab:
7
- * - Merge requests: get, list, changes, discussions, notes (list/create), diffs (paginated)
8
- * - Issues: create, get, list, notes (list/create/get), discussions
9
- * - Epics: get, list, create, update, manage issues, notes (list/create/get), discussions
7
+ * - Merge requests: get, list, changes, create, update, commits, pipelines, diffs (paginated), auto-merge
8
+ * - Issues: create, get, list
9
+ * - Epics: get, list, create, update, manage issues
10
10
  * - Pipelines: list, get, jobs, logs, retry, failing jobs, CI linter
11
11
  * - Repository: get file, commits, diff, branches, tree, create commit, commit comments
12
12
  * - Search: projects, issues, MRs, blobs, commits, etc.
@@ -17,8 +17,8 @@ import { Plugin } from '@opencode-ai/plugin';
17
17
  * - Audit: list project/group/instance audit events
18
18
  * - Wikis: get wiki page
19
19
  * - Work Items: get, list, create, update, notes
20
- * - Snippets: discussions, notes
21
- * - Discussions: universal discussion tools for all resource types
20
+ * - Discussions: unified tools for all resource types (list, get, create/reply, resolve)
21
+ * - Notes: list/get notes (flat view) for MR, issue, epic, snippet
22
22
  * - Git: execute safe, read-only git commands in repository
23
23
  */
24
24
  declare const gitlabPlugin: Plugin;