opencode-gitlab-plugin 2.8.1 → 3.0.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 +29 -0
- package/README.md +54 -12
- package/dist/index.d.ts +36 -4
- package/dist/index.js +174 -59
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +418 -50
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
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
|
+
## [3.0.0](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v2.8.2...v3.0.0) (2026-09-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* the default export is a plugin definition object rather than a
|
|
11
|
+
plugin function. Anything importing the default export and calling it must use
|
|
12
|
+
the named `gitlabPlugin` export instead. OpenCode v1 hosts older than 1.18.29
|
|
13
|
+
do not understand object entrypoints and must stay on 2.x. On OpenCode v2 the
|
|
14
|
+
configuration key is `plugins`, and options move from a tuple to
|
|
15
|
+
`{ "package": "...", "options": { ... } }`; v1's `plugin` key is normalised
|
|
16
|
+
automatically.
|
|
17
|
+
|
|
18
|
+
### ✨ Features
|
|
19
|
+
|
|
20
|
+
* support the v2 plugin SDK ([0b0fe45](https://gitlab.com/vglafirov/opencode-gitlab-plugin/commit/0b0fe4521210820fe4a424499fecaee4d9f55ae6))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 🐛 Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **ci:** sync lockfile with npm 11.6.2 ([ceb68d7](https://gitlab.com/vglafirov/opencode-gitlab-plugin/commit/ceb68d7229d847070233566661472e43f4cdcc3a))
|
|
26
|
+
|
|
27
|
+
## [2.8.2](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v2.8.1...v2.8.2) (2026-09-18)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### 🐛 Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **tools:** validate generated GitLab arguments ([69fcfd5](https://gitlab.com/vglafirov/opencode-gitlab-plugin/commit/69fcfd56c8086f600277da8176a9e5c09b0e8ac5))
|
|
33
|
+
|
|
5
34
|
## [2.8.1](https://gitlab.com/vglafirov/opencode-gitlab-plugin/compare/v2.8.0...v2.8.1) (2026-09-06)
|
|
6
35
|
|
|
7
36
|
|
package/README.md
CHANGED
|
@@ -266,6 +266,14 @@ Full example with lazy-mcp configured in opencode (`~/.config/opencode/opencode.
|
|
|
266
266
|
"command": ["npx", "-y", "lazy-mcp@latest", "--config", "~/.config/lazy-mcp/servers.json"]
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
|
+
"plugins": [{ "package": "opencode-gitlab-plugin", "options": { "tools": false } }]
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
On OpenCode v1, use the legacy tuple form instead:
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
269
277
|
"plugin": [["opencode-gitlab-plugin", { "tools": false }]]
|
|
270
278
|
}
|
|
271
279
|
```
|
|
@@ -298,6 +306,16 @@ export GITLAB_INSTANCE_URL=https://gitlab.example.com
|
|
|
298
306
|
|
|
299
307
|
Add the following plugin to your opencode configuration `~/.config/opencode/opencode.json`:
|
|
300
308
|
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"$schema": "https://opencode.ai/config.json",
|
|
312
|
+
"plugins": ["opencode-gitlab-plugin"]
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
The package ships both plugin SDK entrypoints, so it also works on OpenCode v1 with the
|
|
317
|
+
legacy `plugin` key:
|
|
318
|
+
|
|
301
319
|
```json
|
|
302
320
|
{
|
|
303
321
|
"$schema": "https://opencode.ai/config.json",
|
|
@@ -389,15 +407,15 @@ The plugin provides **64 tools** organized into the following categories:
|
|
|
389
407
|
|
|
390
408
|
### Repository Tools (7 tools)
|
|
391
409
|
|
|
392
|
-
| Tool | Description
|
|
393
|
-
| ----------------------------- |
|
|
394
|
-
| `gitlab_get_file` | Get file contents from
|
|
395
|
-
| `gitlab_get_commit` | Get commit details with metadata, author, and stats
|
|
396
|
-
| `gitlab_list_commits` | List commits with filtering by branch, path, and dates
|
|
397
|
-
| `gitlab_get_commit_diff` | Get diff for a specific commit
|
|
398
|
-
| `gitlab_list_repository_tree` | List files and directories at a given path
|
|
399
|
-
| `gitlab_list_branches` | List all branches in a repository
|
|
400
|
-
| `gitlab_get_commit_comments` | Get all commit comments in flat structure
|
|
410
|
+
| Tool | Description |
|
|
411
|
+
| ----------------------------- | ------------------------------------------------------------- |
|
|
412
|
+
| `gitlab_get_file` | Get file contents from an explicit branch, tag, or commit ref |
|
|
413
|
+
| `gitlab_get_commit` | Get commit details with metadata, author, and stats |
|
|
414
|
+
| `gitlab_list_commits` | List commits with filtering by branch, path, and dates |
|
|
415
|
+
| `gitlab_get_commit_diff` | Get diff for a specific commit |
|
|
416
|
+
| `gitlab_list_repository_tree` | List files and directories at a given path |
|
|
417
|
+
| `gitlab_list_branches` | List all branches in a repository |
|
|
418
|
+
| `gitlab_get_commit_comments` | Get all commit comments in flat structure |
|
|
401
419
|
|
|
402
420
|
### Search Tools (2 tools)
|
|
403
421
|
|
|
@@ -490,9 +508,9 @@ The plugin provides **64 tools** organized into the following categories:
|
|
|
490
508
|
### Example 1: Create and Manage Issues
|
|
491
509
|
|
|
492
510
|
```javascript
|
|
493
|
-
import
|
|
511
|
+
import { allTools } from 'opencode-gitlab-plugin';
|
|
494
512
|
|
|
495
|
-
const plugin =
|
|
513
|
+
const plugin = { tool: allTools };
|
|
496
514
|
|
|
497
515
|
// Create a new issue
|
|
498
516
|
const issue = await plugin.tool.gitlab_create_issue.execute({
|
|
@@ -782,6 +800,7 @@ await plugin.tool.gitlab_link_vulnerability_to_issue.execute({
|
|
|
782
800
|
|
|
783
801
|
```
|
|
784
802
|
opencode-gitlab-plugin/
|
|
803
|
+
├── index.ts # Package-root entrypoint for local v2 plugin loading
|
|
785
804
|
├── src/
|
|
786
805
|
│ ├── client/ # API client modules
|
|
787
806
|
│ │ ├── base.ts # Base client with HTTP & GraphQL methods
|
|
@@ -806,8 +825,12 @@ opencode-gitlab-plugin/
|
|
|
806
825
|
│ │ ├── repository.ts # Repository tool definitions
|
|
807
826
|
│ │ ├── discussions-unified.ts # Unified discussion tools (4 tools)
|
|
808
827
|
│ │ ├── notes-unified.ts # Unified notes tools (3 tools)
|
|
828
|
+
│ │ ├── index.ts # Aggregated tool registries
|
|
809
829
|
│ │ └── ... # Other tool definitions
|
|
810
|
-
│ ├──
|
|
830
|
+
│ ├── v2/ # Plugin SDK v2 entry point
|
|
831
|
+
│ │ ├── plugin.ts # Plugin.define({ id, setup })
|
|
832
|
+
│ │ └── tool-adapter.ts # v1 tool definitions -> v2 tool registrations
|
|
833
|
+
│ ├── index.ts # Main plugin entry point (v2 setup + v1 server)
|
|
811
834
|
│ ├── utils.ts # Utility functions
|
|
812
835
|
│ └── validation.ts # GID validation utilities
|
|
813
836
|
├── tests/ # Test suite (225 tests)
|
|
@@ -863,6 +886,25 @@ npm run format
|
|
|
863
886
|
npm run format:check
|
|
864
887
|
```
|
|
865
888
|
|
|
889
|
+
### Loading a Local Checkout
|
|
890
|
+
|
|
891
|
+
OpenCode v2 resolves a plugin configured by absolute path by probing
|
|
892
|
+
`<directory>/server` and `<directory>/index` — it does **not** read the package's
|
|
893
|
+
`main`/`exports`. The repository root ships an `index.ts` for exactly this, so point
|
|
894
|
+
the config at the checkout root:
|
|
895
|
+
|
|
896
|
+
```json
|
|
897
|
+
{
|
|
898
|
+
"plugins": [{ "package": "/abs/path/to/opencode-gitlab-plugin" }]
|
|
899
|
+
}
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
This loads `src/` directly, so OpenCode's watcher picks up edits without a rebuild.
|
|
903
|
+
Confirm it loaded with `opencode plugin list` — the `gitlab` plugin should be listed.
|
|
904
|
+
|
|
905
|
+
A path to a _file_ (for example `.../dist/index.js`) is rejected with
|
|
906
|
+
`configured plugin path must be a directory`.
|
|
907
|
+
|
|
866
908
|
### Git Hooks
|
|
867
909
|
|
|
868
910
|
The project uses Husky for Git hooks:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _opencode_plugin_promise_plugin from '@opencode/plugin/promise/plugin';
|
|
2
|
+
import { ToolDefinition, Plugin as Plugin$1 } from '@opencode-ai/plugin';
|
|
3
|
+
import { Plugin } from '@opencode/plugin';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Tools exposed over the standalone MCP server (`opencode-gitlab-plugin` binary).
|
|
7
|
+
*/
|
|
8
|
+
declare const mcpTools: Record<string, ToolDefinition>;
|
|
9
|
+
/**
|
|
10
|
+
* Every tool registered by the OpenCode plugin.
|
|
11
|
+
*/
|
|
12
|
+
declare const allTools: Record<string, ToolDefinition>;
|
|
13
|
+
|
|
14
|
+
declare const PLUGIN_ID = "gitlab";
|
|
15
|
+
/**
|
|
16
|
+
* GitLab Tools Plugin for OpenCode (plugin SDK v2)
|
|
5
17
|
*
|
|
6
18
|
* Provides tools for interacting with GitLab:
|
|
7
19
|
* - Merge requests: get, list, changes, create, update, commits, pipelines, diffs (paginated), auto-merge
|
|
@@ -22,6 +34,26 @@ import { Plugin } from '@opencode-ai/plugin';
|
|
|
22
34
|
* - Git: execute safe, read-only git commands in repository
|
|
23
35
|
* - Orbit: Knowledge Graph API (status, schema, query, neighbors)
|
|
24
36
|
*/
|
|
25
|
-
declare const
|
|
37
|
+
declare const gitlabPluginV2: Plugin.Plugin;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* GitLab Tools Plugin for OpenCode — legacy (v1) plugin SDK entrypoint.
|
|
41
|
+
*
|
|
42
|
+
* Kept so the package keeps working on OpenCode v1. New installs use the v2
|
|
43
|
+
* `setup()` implementation in `./v2/plugin.ts`.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Use the default export with the v2 plugin SDK.
|
|
46
|
+
*/
|
|
47
|
+
declare const gitlabPlugin: Plugin$1;
|
|
48
|
+
/**
|
|
49
|
+
* Dual entrypoint: OpenCode v2 calls `setup()`, OpenCode v1 calls `server()`.
|
|
50
|
+
*
|
|
51
|
+
* See https://opencode.ai/v2/docs/build/plugins/migrate-v1
|
|
52
|
+
*/
|
|
53
|
+
declare const _default: {
|
|
54
|
+
server: Plugin$1;
|
|
55
|
+
id: string;
|
|
56
|
+
setup: (context: _opencode_plugin_promise_plugin.Context) => Promise<_opencode_plugin_promise_plugin.Cleanup | void> | _opencode_plugin_promise_plugin.Cleanup | void;
|
|
57
|
+
};
|
|
26
58
|
|
|
27
|
-
export {
|
|
59
|
+
export { PLUGIN_ID, allTools, _default as default, gitlabPlugin, gitlabPluginV2, mcpTools };
|
package/dist/index.js
CHANGED
|
@@ -129,19 +129,45 @@ var GitLabApiClient = class {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
// src/client/
|
|
133
|
-
|
|
132
|
+
// src/client/connection-pagination.ts
|
|
133
|
+
var DEFAULT_PAGE_SIZE = 20;
|
|
134
|
+
var MAX_PAGE_SIZE = 100;
|
|
135
|
+
function normalizePageSize(value) {
|
|
136
|
+
if (value === void 0 || value === 0) return void 0;
|
|
137
|
+
if (!Number.isFinite(value)) return DEFAULT_PAGE_SIZE;
|
|
138
|
+
return Math.min(Math.max(Math.floor(value), 1), MAX_PAGE_SIZE);
|
|
139
|
+
}
|
|
140
|
+
function buildConnectionVariables(options) {
|
|
134
141
|
const variables = {};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
const first = normalizePageSize(options?.first);
|
|
143
|
+
const last = normalizePageSize(options?.last);
|
|
144
|
+
if (first !== void 0 && last !== void 0) {
|
|
145
|
+
throw new Error("Pagination accepts either 'first' or 'last', not both");
|
|
146
|
+
}
|
|
147
|
+
if (options?.after && last !== void 0) {
|
|
148
|
+
throw new Error("Pagination cursor 'after' cannot be combined with 'last'");
|
|
149
|
+
}
|
|
150
|
+
if (options?.before && first !== void 0) {
|
|
151
|
+
throw new Error("Pagination cursor 'before' cannot be combined with 'first'");
|
|
152
|
+
}
|
|
153
|
+
if (first !== void 0) {
|
|
154
|
+
variables.first = first;
|
|
155
|
+
} else if (last !== void 0) {
|
|
156
|
+
variables.last = last;
|
|
157
|
+
} else if (options?.before) {
|
|
158
|
+
variables.last = DEFAULT_PAGE_SIZE;
|
|
159
|
+
} else {
|
|
160
|
+
variables.first = DEFAULT_PAGE_SIZE;
|
|
139
161
|
}
|
|
140
162
|
if (options?.after) variables.after = options.after;
|
|
141
|
-
if (options?.last !== void 0) variables.last = options.last;
|
|
142
163
|
if (options?.before) variables.before = options.before;
|
|
143
164
|
return variables;
|
|
144
165
|
}
|
|
166
|
+
|
|
167
|
+
// src/client/notes-types.ts
|
|
168
|
+
function buildPaginationVariables(options) {
|
|
169
|
+
return buildConnectionVariables(options);
|
|
170
|
+
}
|
|
145
171
|
var NOTES_FRAGMENT = `
|
|
146
172
|
fragment NoteFields on Note {
|
|
147
173
|
id
|
|
@@ -180,16 +206,7 @@ var NOTES_CONNECTION_FRAGMENT = `
|
|
|
180
206
|
|
|
181
207
|
// src/client/discussions-types.ts
|
|
182
208
|
function buildDiscussionsPaginationVariables(options) {
|
|
183
|
-
|
|
184
|
-
if (options?.first !== void 0) {
|
|
185
|
-
variables.first = options.first;
|
|
186
|
-
} else if (options?.last == null) {
|
|
187
|
-
variables.first = 20;
|
|
188
|
-
}
|
|
189
|
-
if (options?.after) variables.after = options.after;
|
|
190
|
-
if (options?.last !== void 0) variables.last = options.last;
|
|
191
|
-
if (options?.before) variables.before = options.before;
|
|
192
|
-
return variables;
|
|
209
|
+
return buildConnectionVariables(options);
|
|
193
210
|
}
|
|
194
211
|
var DISCUSSION_NOTE_FRAGMENT = `
|
|
195
212
|
fragment DiscussionNoteFields on Note {
|
|
@@ -1449,10 +1466,7 @@ var RepositoryClient = class extends GitLabApiClient {
|
|
|
1449
1466
|
async getFile(projectId, filePath, ref) {
|
|
1450
1467
|
const encodedProject = this.encodeProjectId(projectId);
|
|
1451
1468
|
const encodedPath = encodeURIComponent(filePath);
|
|
1452
|
-
|
|
1453
|
-
if (ref) {
|
|
1454
|
-
url += `?ref=${encodeURIComponent(ref)}`;
|
|
1455
|
-
}
|
|
1469
|
+
const url = `/projects/${encodedProject}/repository/files/${encodedPath}?ref=${encodeURIComponent(ref)}`;
|
|
1456
1470
|
const file = await this.fetch("GET", url);
|
|
1457
1471
|
if (file.encoding === "base64") {
|
|
1458
1472
|
return Buffer.from(file.content, "base64").toString("utf-8");
|
|
@@ -3546,13 +3560,13 @@ var repositoryTools = {
|
|
|
3546
3560
|
gitlab_get_file: tool5({
|
|
3547
3561
|
description: `Get the contents of a file from a repository.
|
|
3548
3562
|
Supports fetching files from any branch, tag, or commit SHA.
|
|
3549
|
-
|
|
3563
|
+
An explicit ref is required by the GitLab repository files API.
|
|
3550
3564
|
Note: Invalid refs will result in a 404 error from the GitLab API.`,
|
|
3551
3565
|
args: {
|
|
3552
3566
|
project_id: z5.string().describe("The project ID or URL-encoded path"),
|
|
3553
3567
|
file_path: z5.string().describe("Path to the file in the repository"),
|
|
3554
|
-
ref: z5.string().
|
|
3555
|
-
|
|
3568
|
+
ref: z5.string().trim().min(1).describe(
|
|
3569
|
+
"Branch name, tag, or commit SHA to fetch the file from. Supports full or short commit SHAs."
|
|
3556
3570
|
)
|
|
3557
3571
|
},
|
|
3558
3572
|
execute: async (args, _ctx) => {
|
|
@@ -3730,6 +3744,8 @@ Scopes and their requirements:
|
|
|
3730
3744
|
- wiki_blobs: Search wiki content (supports ref filter)
|
|
3731
3745
|
- group_projects: Search projects within a group (requires group_id)
|
|
3732
3746
|
|
|
3747
|
+
For scopes other than milestones, state="all" is treated as omitted because it does not filter results.
|
|
3748
|
+
|
|
3733
3749
|
Examples:
|
|
3734
3750
|
- Issues: scope="issues", search="bug", project_id="my-group/my-project"
|
|
3735
3751
|
- Code: scope="blobs", search="function calculateTotal"
|
|
@@ -3764,6 +3780,9 @@ Examples:
|
|
|
3764
3780
|
state: z6.enum(["active", "closed", "all"]).optional().describe("Filter by state (for milestones scope)")
|
|
3765
3781
|
},
|
|
3766
3782
|
execute: async (args, _ctx) => {
|
|
3783
|
+
if (args.scope !== "milestones" && args.state === "all") {
|
|
3784
|
+
args.state = void 0;
|
|
3785
|
+
}
|
|
3767
3786
|
validateSearchParams(args.scope, {
|
|
3768
3787
|
project_id: args.project_id,
|
|
3769
3788
|
group_id: args.group_id,
|
|
@@ -4472,10 +4491,10 @@ Examples:
|
|
|
4472
4491
|
"Filter by resolved status: true for resolved, false for unresolved. Only returns resolvable discussions (excludes system notes). Client-side filtering."
|
|
4473
4492
|
),
|
|
4474
4493
|
// Pagination
|
|
4475
|
-
first: z13.number().optional().describe("Number of items to return (default: 20)"),
|
|
4494
|
+
first: z13.number().int().min(0).max(100).optional().describe("Number of items to return (default: 20, max: 100; 0 uses the default)"),
|
|
4476
4495
|
after: z13.string().optional().describe("Cursor for pagination - use endCursor from previous response"),
|
|
4477
4496
|
before: z13.string().optional().describe("Cursor for backward pagination"),
|
|
4478
|
-
last: z13.number().optional().describe("Number of items from the end")
|
|
4497
|
+
last: z13.number().int().min(0).max(100).optional().describe("Number of items from the end (max: 100; 0 is omitted)")
|
|
4479
4498
|
},
|
|
4480
4499
|
execute: async (args, _ctx) => {
|
|
4481
4500
|
validateResourceParams(args.resource_type, args);
|
|
@@ -4788,9 +4807,11 @@ Examples:
|
|
|
4788
4807
|
"Filter by resolved status: true for resolved, false for unresolved. Only returns resolvable notes (excludes system notes). Client-side filtering."
|
|
4789
4808
|
),
|
|
4790
4809
|
// Pagination
|
|
4791
|
-
first: z14.number().
|
|
4810
|
+
first: z14.number().int().min(0).max(100).optional().describe(
|
|
4811
|
+
"Number of items to return from the beginning (default: 20, max: 100; 0 uses the default)"
|
|
4812
|
+
),
|
|
4792
4813
|
after: z14.string().optional().describe("Cursor for forward pagination - use endCursor from previous response"),
|
|
4793
|
-
last: z14.number().optional().describe("Number of items to return from the end (
|
|
4814
|
+
last: z14.number().int().min(0).max(100).optional().describe("Number of items to return from the end (max: 100; 0 is omitted)"),
|
|
4794
4815
|
before: z14.string().optional().describe("Cursor for backward pagination - use startCursor from previous response")
|
|
4795
4816
|
},
|
|
4796
4817
|
execute: async (args, _ctx) => {
|
|
@@ -5768,45 +5789,139 @@ then use that ID (e.g., 377844873).`,
|
|
|
5768
5789
|
})
|
|
5769
5790
|
};
|
|
5770
5791
|
|
|
5792
|
+
// src/tools/index.ts
|
|
5793
|
+
var mcpTools = {
|
|
5794
|
+
...mergeRequestTools,
|
|
5795
|
+
...issueTools,
|
|
5796
|
+
...epicTools,
|
|
5797
|
+
...pipelineTools,
|
|
5798
|
+
...repositoryTools,
|
|
5799
|
+
...searchTools,
|
|
5800
|
+
...projectTools,
|
|
5801
|
+
...userTools,
|
|
5802
|
+
...securityTools,
|
|
5803
|
+
...todoTools,
|
|
5804
|
+
...wikiTools,
|
|
5805
|
+
...workItemTools,
|
|
5806
|
+
...discussionsUnifiedTools,
|
|
5807
|
+
...notesUnifiedTools,
|
|
5808
|
+
...gitTools,
|
|
5809
|
+
...auditTools,
|
|
5810
|
+
...awardEmojiTools
|
|
5811
|
+
};
|
|
5812
|
+
var allTools = {
|
|
5813
|
+
...mcpTools,
|
|
5814
|
+
...orbitTools
|
|
5815
|
+
};
|
|
5816
|
+
|
|
5817
|
+
// src/v2/plugin.ts
|
|
5818
|
+
import { Plugin } from "@opencode/plugin";
|
|
5819
|
+
|
|
5820
|
+
// src/v2/tool-adapter.ts
|
|
5821
|
+
import { tool as tool19 } from "@opencode-ai/plugin";
|
|
5822
|
+
var z19 = tool19.schema;
|
|
5823
|
+
function toInputSchema(args) {
|
|
5824
|
+
const schema = z19.toJSONSchema(z19.object(args ?? {}), { io: "input" });
|
|
5825
|
+
delete schema["$schema"];
|
|
5826
|
+
return {
|
|
5827
|
+
type: "object",
|
|
5828
|
+
properties: {},
|
|
5829
|
+
additionalProperties: false,
|
|
5830
|
+
...schema
|
|
5831
|
+
};
|
|
5832
|
+
}
|
|
5833
|
+
function toToolResult(result) {
|
|
5834
|
+
if (typeof result === "string") {
|
|
5835
|
+
return { content: result };
|
|
5836
|
+
}
|
|
5837
|
+
const metadata = { ...result.metadata ?? {} };
|
|
5838
|
+
if (result.title !== void 0) metadata["title"] = result.title;
|
|
5839
|
+
if (result.attachments !== void 0) metadata["attachments"] = result.attachments;
|
|
5840
|
+
return {
|
|
5841
|
+
content: result.output,
|
|
5842
|
+
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
5843
|
+
};
|
|
5844
|
+
}
|
|
5845
|
+
function toLegacyContext(context, directory, worktree) {
|
|
5846
|
+
return {
|
|
5847
|
+
sessionID: context.sessionID,
|
|
5848
|
+
messageID: context.messageID,
|
|
5849
|
+
agent: context.agent,
|
|
5850
|
+
directory,
|
|
5851
|
+
worktree,
|
|
5852
|
+
abort: context.signal,
|
|
5853
|
+
metadata: (update) => void context.progress(update),
|
|
5854
|
+
ask: async () => {
|
|
5855
|
+
}
|
|
5856
|
+
};
|
|
5857
|
+
}
|
|
5858
|
+
function adaptTool(name, definition, options) {
|
|
5859
|
+
const validator = z19.object(definition.args ?? {});
|
|
5860
|
+
return {
|
|
5861
|
+
name,
|
|
5862
|
+
description: definition.description,
|
|
5863
|
+
input: toInputSchema(definition.args),
|
|
5864
|
+
async execute(input, context) {
|
|
5865
|
+
const parsed = validator.parse(input ?? {});
|
|
5866
|
+
const legacyContext = toLegacyContext(context, options.directory, options.worktree);
|
|
5867
|
+
const result = await definition.execute(
|
|
5868
|
+
parsed,
|
|
5869
|
+
legacyContext
|
|
5870
|
+
);
|
|
5871
|
+
return toToolResult(result);
|
|
5872
|
+
}
|
|
5873
|
+
};
|
|
5874
|
+
}
|
|
5875
|
+
function adaptTools(tools, options) {
|
|
5876
|
+
return Object.entries(tools).map(([name, definition]) => adaptTool(name, definition, options));
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5879
|
+
// src/v2/plugin.ts
|
|
5880
|
+
var PLUGIN_ID = "gitlab";
|
|
5881
|
+
var LAZY_MCP_HINT = `## GitLab Tools via lazy-mcp
|
|
5882
|
+
GitLab API tools (MRs, issues, pipelines, security, search, repos, users, todos, work items, discussions, notes, audit, git, award emoji) are served via the "gitlab" MCP server through lazy-mcp. Use lazy-mcp_list_commands with server "gitlab" to discover and call them.
|
|
5883
|
+
DAP tools (agents, flows, memory, skills) are on the "gitlab-dap" server instead.`;
|
|
5884
|
+
var gitlabPluginV2 = Plugin.define({
|
|
5885
|
+
id: PLUGIN_ID,
|
|
5886
|
+
async setup(ctx) {
|
|
5887
|
+
if (ctx.options["tools"] === false) {
|
|
5888
|
+
await ctx.session.hook("context", (event) => {
|
|
5889
|
+
event.system.push({ type: "text", text: LAZY_MCP_HINT });
|
|
5890
|
+
});
|
|
5891
|
+
return;
|
|
5892
|
+
}
|
|
5893
|
+
const directory = ctx.location.directory;
|
|
5894
|
+
const worktree = ctx.location.project.directory ?? directory;
|
|
5895
|
+
const tools = adaptTools(allTools, { directory, worktree });
|
|
5896
|
+
await ctx.tool.transform((editor) => {
|
|
5897
|
+
for (const definition of tools) {
|
|
5898
|
+
editor.add(definition);
|
|
5899
|
+
}
|
|
5900
|
+
});
|
|
5901
|
+
}
|
|
5902
|
+
});
|
|
5903
|
+
|
|
5771
5904
|
// src/index.ts
|
|
5772
5905
|
var gitlabPlugin = async (_input, options) => {
|
|
5773
|
-
if (options?.tools === false) {
|
|
5906
|
+
if (options?.["tools"] === false) {
|
|
5774
5907
|
return {
|
|
5775
|
-
"experimental.chat.system.transform": async (
|
|
5776
|
-
output.system.push(
|
|
5777
|
-
`## GitLab Tools via lazy-mcp
|
|
5778
|
-
GitLab API tools (MRs, issues, pipelines, security, search, repos, users, todos, work items, discussions, notes, audit, git, award emoji) are served via the "gitlab" MCP server through lazy-mcp. Use lazy-mcp_list_commands with server "gitlab" to discover and call them.
|
|
5779
|
-
DAP tools (agents, flows, memory, skills) are on the "gitlab-dap" server instead.`
|
|
5780
|
-
);
|
|
5908
|
+
"experimental.chat.system.transform": async (_hookInput, output) => {
|
|
5909
|
+
output.system.push(LAZY_MCP_HINT);
|
|
5781
5910
|
}
|
|
5782
5911
|
};
|
|
5783
5912
|
}
|
|
5784
|
-
return {
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
...pipelineTools,
|
|
5790
|
-
...repositoryTools,
|
|
5791
|
-
...searchTools,
|
|
5792
|
-
...projectTools,
|
|
5793
|
-
...userTools,
|
|
5794
|
-
...securityTools,
|
|
5795
|
-
...todoTools,
|
|
5796
|
-
...wikiTools,
|
|
5797
|
-
...workItemTools,
|
|
5798
|
-
...discussionsUnifiedTools,
|
|
5799
|
-
...notesUnifiedTools,
|
|
5800
|
-
...gitTools,
|
|
5801
|
-
...auditTools,
|
|
5802
|
-
...awardEmojiTools,
|
|
5803
|
-
...orbitTools
|
|
5804
|
-
}
|
|
5805
|
-
};
|
|
5913
|
+
return { tool: allTools };
|
|
5914
|
+
};
|
|
5915
|
+
var index_default = {
|
|
5916
|
+
...gitlabPluginV2,
|
|
5917
|
+
server: gitlabPlugin
|
|
5806
5918
|
};
|
|
5807
|
-
var index_default = gitlabPlugin;
|
|
5808
5919
|
export {
|
|
5920
|
+
PLUGIN_ID,
|
|
5921
|
+
allTools,
|
|
5809
5922
|
index_default as default,
|
|
5810
|
-
gitlabPlugin
|
|
5923
|
+
gitlabPlugin,
|
|
5924
|
+
gitlabPluginV2,
|
|
5925
|
+
mcpTools
|
|
5811
5926
|
};
|
|
5812
5927
|
//# sourceMappingURL=index.js.map
|