@open-cr-agent/vcs-gitlab 0.1.2
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/LICENSE +202 -0
- package/README.md +3 -0
- package/dist/adapter.d.ts +15 -0
- package/dist/adapter.js +195 -0
- package/dist/client.d.ts +107 -0
- package/dist/client.js +233 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.js +43 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# @open-cr-agent/vcs-gitlab
|
|
2
|
+
|
|
3
|
+
The adapter for GitLab merge requests of [Open-CR-Agent](https://github.com/jma49/Open-CR-Agent), the multi-agent code reviewer, on GitLab.com and self-managed GitLab. Most users want [`@open-cr-agent/cli`](https://www.npmjs.com/package/@open-cr-agent/cli), which provides the `ocra` command and installs this package; see the [manual](https://ocra.majincheng.com). All `@open-cr-agent` packages are released together at one version. Apache-2.0.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FileDiff } from "@open-cr-agent/core";
|
|
2
|
+
import { type CodeSource, type History, PlatformReview } from "@open-cr-agent/vcs-platform";
|
|
3
|
+
import { type GitLabApi, type MergeRequest, type Position } from "./client.js";
|
|
4
|
+
export interface GitLabAdapterOptions {
|
|
5
|
+
iid: number;
|
|
6
|
+
api: GitLabApi;
|
|
7
|
+
code: CodeSource;
|
|
8
|
+
history?: History;
|
|
9
|
+
snapshot?: MergeRequest;
|
|
10
|
+
}
|
|
11
|
+
export declare class GitLabAdapter extends PlatformReview {
|
|
12
|
+
constructor(options: GitLabAdapterOptions);
|
|
13
|
+
}
|
|
14
|
+
export declare function positionOf(file: string, line: number, diffs: readonly FileDiff[], refs: NonNullable<MergeRequest["diff_refs"]>): Position | undefined;
|
|
15
|
+
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { errorMessage } from "@open-cr-agent/core";
|
|
2
|
+
import { PlatformReview, } from "@open-cr-agent/vcs-platform";
|
|
3
|
+
import { DEVELOPER, GitLabApiError, } from "./client.js";
|
|
4
|
+
// A GitLab merge request as ocra's review conversation (vcs-platform).
|
|
5
|
+
export class GitLabAdapter extends PlatformReview {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super({
|
|
8
|
+
name: "gitlab",
|
|
9
|
+
platform: new GitLabPlatform(options),
|
|
10
|
+
code: options.code,
|
|
11
|
+
...(options.history ? { history: options.history } : {}),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// A note whose editor is not in the GraphQL answer (past its page cap) reads
|
|
16
|
+
// as edited by nobody who could be its author or ocra: the rules then ignore
|
|
17
|
+
// it rather than trust it. Parentheses cannot occur in a GitLab username.
|
|
18
|
+
const UNKNOWN_EDITOR = "(unknown)";
|
|
19
|
+
class GitLabPlatform {
|
|
20
|
+
options;
|
|
21
|
+
text = { changeRequest: "merge request", authority: "the Developer role or higher" };
|
|
22
|
+
mergeRequest;
|
|
23
|
+
user;
|
|
24
|
+
editors;
|
|
25
|
+
// User ids by username, from the notes read, for membership lookups.
|
|
26
|
+
ids = new Map();
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
// The token's own user: a project access token has a bot user of its own.
|
|
31
|
+
async bot() {
|
|
32
|
+
this.user ??= this.options.api.currentUser();
|
|
33
|
+
const { username } = await this.user;
|
|
34
|
+
return { login: username, is: (other) => other === username };
|
|
35
|
+
}
|
|
36
|
+
async changeRequest() {
|
|
37
|
+
const mr = await this.mr();
|
|
38
|
+
const refs = diffRefs(mr);
|
|
39
|
+
return {
|
|
40
|
+
id: `${projectPath(mr.web_url)}!${mr.iid}`,
|
|
41
|
+
title: mr.title,
|
|
42
|
+
description: mr.description ?? "",
|
|
43
|
+
baseSha: refs.start_sha,
|
|
44
|
+
headSha: refs.head_sha,
|
|
45
|
+
...(mr.author ? { author: mr.author.username } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Comments on the merge request as a whole: plain notes and the notes of
|
|
49
|
+
// threads started on it, not notes on lines or system notes.
|
|
50
|
+
async comments() {
|
|
51
|
+
const notes = await this.options.api.listNotes(this.options.iid);
|
|
52
|
+
return notes
|
|
53
|
+
.filter((n) => !n.system && n.type !== "DiffNote")
|
|
54
|
+
.map((n) => {
|
|
55
|
+
this.remember(n);
|
|
56
|
+
return { id: String(n.id), author: n.author.username, body: n.body };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async editor(comment) {
|
|
60
|
+
const editors = await this.noteEditors();
|
|
61
|
+
const id = Number(comment.id);
|
|
62
|
+
if (!editors.has(id))
|
|
63
|
+
throw new Error(`GitLab did not say who last edited note ${id}`);
|
|
64
|
+
return editors.get(id);
|
|
65
|
+
}
|
|
66
|
+
async canWrite(login) {
|
|
67
|
+
const id = this.ids.get(login) ?? (await this.options.api.findUser(login));
|
|
68
|
+
if (id === undefined)
|
|
69
|
+
return false;
|
|
70
|
+
return (await this.options.api.accessLevel(id)) >= DEVELOPER;
|
|
71
|
+
}
|
|
72
|
+
async threads() {
|
|
73
|
+
const discussions = await this.options.api.listDiscussions(this.options.iid);
|
|
74
|
+
// Without editors every reply would read as unedited, so no threads.
|
|
75
|
+
// Read after the discussions, not reused from the summary's check: a note
|
|
76
|
+
// edited in between then reads as edited, never as unedited.
|
|
77
|
+
const editors = await this.options.api.noteEditors(this.options.iid);
|
|
78
|
+
// Where a push resolves outdated threads, GitLab records the pusher as
|
|
79
|
+
// the one who resolved them, so no resolution says who dismissed what.
|
|
80
|
+
const attributable = (await this.options.api.resolvesOutdatedThreads().catch(() => undefined)) === false;
|
|
81
|
+
return discussions
|
|
82
|
+
.filter((d) => !d.individual_note)
|
|
83
|
+
.flatMap((d) => {
|
|
84
|
+
const notes = d.notes.filter((n) => !n.system);
|
|
85
|
+
const first = notes[0];
|
|
86
|
+
if (!first)
|
|
87
|
+
return [];
|
|
88
|
+
for (const n of notes)
|
|
89
|
+
this.remember(n);
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
id: d.id,
|
|
93
|
+
resolved: first.resolved === true,
|
|
94
|
+
...(first.resolved_by && attributable
|
|
95
|
+
? { resolvedBy: first.resolved_by.username }
|
|
96
|
+
: {}),
|
|
97
|
+
comments: notes.map((n) => {
|
|
98
|
+
const editor = editors.has(n.id) ? editors.get(n.id) : UNKNOWN_EDITOR;
|
|
99
|
+
return { author: n.author.username, body: n.body, ...(editor ? { editor } : {}) };
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// One thread per finding, each its own request: a position GitLab
|
|
106
|
+
// rejects (400) leaves that finding in the summary, and any other failure
|
|
107
|
+
// is a warning, so one bad comment never costs the rest or the summary.
|
|
108
|
+
async publishFindings(_report, fresh) {
|
|
109
|
+
if (fresh.length === 0)
|
|
110
|
+
return { posted: [], warnings: [] };
|
|
111
|
+
const refs = diffRefs(await this.mr());
|
|
112
|
+
const diffs = await this.options.code.getDiff();
|
|
113
|
+
const posted = [];
|
|
114
|
+
const warnings = [];
|
|
115
|
+
for (const { finding, body } of fresh) {
|
|
116
|
+
const position = positionOf(finding.file, finding.lineRange.end, diffs, refs);
|
|
117
|
+
if (!position)
|
|
118
|
+
continue;
|
|
119
|
+
try {
|
|
120
|
+
await this.options.api.createDiscussion(this.options.iid, body, position);
|
|
121
|
+
posted.push(finding.fingerprint);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error instanceof GitLabApiError && error.status === 400)
|
|
125
|
+
continue;
|
|
126
|
+
warnings.push(`could not comment on ${finding.file}:${finding.lineRange.end}: ${errorMessage(error)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { posted, warnings };
|
|
130
|
+
}
|
|
131
|
+
async writeSummary(existing, body) {
|
|
132
|
+
if (existing)
|
|
133
|
+
await this.options.api.updateNote(this.options.iid, Number(existing.id), body);
|
|
134
|
+
else
|
|
135
|
+
await this.options.api.createNote(this.options.iid, body);
|
|
136
|
+
}
|
|
137
|
+
resolveThread(id) {
|
|
138
|
+
return this.options.api.resolveDiscussion(this.options.iid, id);
|
|
139
|
+
}
|
|
140
|
+
remember(note) {
|
|
141
|
+
this.ids.set(note.author.username, note.author.id);
|
|
142
|
+
if (note.resolved_by)
|
|
143
|
+
this.ids.set(note.resolved_by.username, note.resolved_by.id);
|
|
144
|
+
}
|
|
145
|
+
noteEditors() {
|
|
146
|
+
this.editors ??= this.options.api.noteEditors(this.options.iid);
|
|
147
|
+
return this.editors;
|
|
148
|
+
}
|
|
149
|
+
mr() {
|
|
150
|
+
this.mergeRequest ??= this.options.snapshot
|
|
151
|
+
? Promise.resolve(this.options.snapshot)
|
|
152
|
+
: this.options.api.getMergeRequest(this.options.iid);
|
|
153
|
+
return this.mergeRequest;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function diffRefs(mr) {
|
|
157
|
+
if (!mr.diff_refs)
|
|
158
|
+
throw new Error(`merge request !${mr.iid} has no diff yet; try again shortly`);
|
|
159
|
+
return mr.diff_refs;
|
|
160
|
+
}
|
|
161
|
+
// "https://gitlab.example.com/group/sub/project/-/merge_requests/7" names
|
|
162
|
+
// the project "group/sub/project".
|
|
163
|
+
function projectPath(webUrl) {
|
|
164
|
+
try {
|
|
165
|
+
return new URL(webUrl).pathname.split("/-/")[0]?.replace(/^\/+/, "") ?? webUrl;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return webUrl;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Where GitLab puts a comment on the new version's line: an added line takes
|
|
172
|
+
// its new number, an unchanged one both; a line outside the diff has none.
|
|
173
|
+
export function positionOf(file, line, diffs, refs) {
|
|
174
|
+
const diff = diffs.find((d) => d.newPath === file);
|
|
175
|
+
if (!diff)
|
|
176
|
+
return undefined;
|
|
177
|
+
for (const hunk of diff.hunks) {
|
|
178
|
+
for (const l of hunk.lines) {
|
|
179
|
+
if (l.kind === "delete" || l.newLine !== line)
|
|
180
|
+
continue;
|
|
181
|
+
return {
|
|
182
|
+
position_type: "text",
|
|
183
|
+
base_sha: refs.base_sha,
|
|
184
|
+
start_sha: refs.start_sha,
|
|
185
|
+
head_sha: refs.head_sha,
|
|
186
|
+
old_path: diff.oldPath,
|
|
187
|
+
new_path: diff.newPath,
|
|
188
|
+
new_line: line,
|
|
189
|
+
...(l.kind === "context" ? { old_line: l.oldLine } : {}),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=adapter.js.map
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const mergeRequestSchema: z.ZodObject<{
|
|
3
|
+
iid: z.ZodNumber;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
description: z.ZodNullable<z.ZodString>;
|
|
6
|
+
author: z.ZodNullable<z.ZodObject<{
|
|
7
|
+
id: z.ZodNumber;
|
|
8
|
+
username: z.ZodString;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
web_url: z.ZodString;
|
|
11
|
+
source_project_id: z.ZodNumber;
|
|
12
|
+
target_project_id: z.ZodNumber;
|
|
13
|
+
diff_refs: z.ZodNullable<z.ZodObject<{
|
|
14
|
+
base_sha: z.ZodString;
|
|
15
|
+
start_sha: z.ZodString;
|
|
16
|
+
head_sha: z.ZodString;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type MergeRequest = z.infer<typeof mergeRequestSchema>;
|
|
20
|
+
declare const noteSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodNumber;
|
|
22
|
+
body: z.ZodString;
|
|
23
|
+
author: z.ZodObject<{
|
|
24
|
+
id: z.ZodNumber;
|
|
25
|
+
username: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
system: z.ZodBoolean;
|
|
28
|
+
type: z.ZodNullable<z.ZodString>;
|
|
29
|
+
resolvable: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
resolved: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
resolved_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
32
|
+
id: z.ZodNumber;
|
|
33
|
+
username: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type Note = z.infer<typeof noteSchema>;
|
|
37
|
+
declare const discussionSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
individual_note: z.ZodBoolean;
|
|
40
|
+
notes: z.ZodArray<z.ZodObject<{
|
|
41
|
+
id: z.ZodNumber;
|
|
42
|
+
body: z.ZodString;
|
|
43
|
+
author: z.ZodObject<{
|
|
44
|
+
id: z.ZodNumber;
|
|
45
|
+
username: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
system: z.ZodBoolean;
|
|
48
|
+
type: z.ZodNullable<z.ZodString>;
|
|
49
|
+
resolvable: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
resolved: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
resolved_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
52
|
+
id: z.ZodNumber;
|
|
53
|
+
username: z.ZodString;
|
|
54
|
+
}, z.core.$strip>>>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type Discussion = z.infer<typeof discussionSchema>;
|
|
58
|
+
export interface Position {
|
|
59
|
+
position_type: "text";
|
|
60
|
+
base_sha: string;
|
|
61
|
+
start_sha: string;
|
|
62
|
+
head_sha: string;
|
|
63
|
+
old_path: string;
|
|
64
|
+
new_path: string;
|
|
65
|
+
new_line: number;
|
|
66
|
+
old_line?: number;
|
|
67
|
+
}
|
|
68
|
+
export declare class GitLabApiError extends Error {
|
|
69
|
+
readonly status: number;
|
|
70
|
+
constructor(status: number, message: string);
|
|
71
|
+
}
|
|
72
|
+
export interface GitLabApiOptions {
|
|
73
|
+
token: string;
|
|
74
|
+
baseUrl?: string;
|
|
75
|
+
fetch?: typeof fetch;
|
|
76
|
+
sleep?: (ms: number) => Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export declare const DEVELOPER = 30;
|
|
79
|
+
export declare class GitLabApi {
|
|
80
|
+
private readonly project;
|
|
81
|
+
private readonly options;
|
|
82
|
+
private readonly baseUrl;
|
|
83
|
+
private readonly fetchImpl;
|
|
84
|
+
constructor(project: string | number, options: GitLabApiOptions);
|
|
85
|
+
currentUser(): Promise<{
|
|
86
|
+
id: number;
|
|
87
|
+
username: string;
|
|
88
|
+
}>;
|
|
89
|
+
fullPath(): Promise<string>;
|
|
90
|
+
resolvesOutdatedThreads(): Promise<boolean | undefined>;
|
|
91
|
+
getMergeRequest(iid: number): Promise<MergeRequest>;
|
|
92
|
+
listNotes(iid: number): Promise<Note[]>;
|
|
93
|
+
listDiscussions(iid: number): Promise<Discussion[]>;
|
|
94
|
+
createNote(iid: number, body: string): Promise<void>;
|
|
95
|
+
updateNote(iid: number, noteId: number, body: string): Promise<void>;
|
|
96
|
+
createDiscussion(iid: number, body: string, position: Position): Promise<void>;
|
|
97
|
+
resolveDiscussion(iid: number, discussionId: string): Promise<void>;
|
|
98
|
+
accessLevel(userId: number): Promise<number>;
|
|
99
|
+
findUser(username: string): Promise<number | undefined>;
|
|
100
|
+
noteEditors(iid: number): Promise<Map<number, string | undefined>>;
|
|
101
|
+
private pages;
|
|
102
|
+
private graphql;
|
|
103
|
+
private request;
|
|
104
|
+
private send;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { retryDecision } from "@open-cr-agent/vcs-platform";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// Commit ids reach git as arguments; anything else is refused at the boundary.
|
|
4
|
+
const sha = z.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/, "not a commit id");
|
|
5
|
+
const user = z.object({ id: z.number(), username: z.string() });
|
|
6
|
+
const mergeRequestSchema = z.object({
|
|
7
|
+
iid: z.number(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
description: z.string().nullable(),
|
|
10
|
+
author: user.nullable(),
|
|
11
|
+
web_url: z.string(),
|
|
12
|
+
source_project_id: z.number(),
|
|
13
|
+
target_project_id: z.number(),
|
|
14
|
+
// Null while GitLab is still preparing the diff of a new merge request.
|
|
15
|
+
diff_refs: z.object({ base_sha: sha, start_sha: sha, head_sha: sha }).nullable(),
|
|
16
|
+
});
|
|
17
|
+
const noteSchema = z.object({
|
|
18
|
+
id: z.number(),
|
|
19
|
+
body: z.string(),
|
|
20
|
+
author: user,
|
|
21
|
+
system: z.boolean(),
|
|
22
|
+
// null for a plain comment, "DiscussionNote" in a thread, "DiffNote" on a line.
|
|
23
|
+
type: z.string().nullable(),
|
|
24
|
+
resolvable: z.boolean().optional(),
|
|
25
|
+
resolved: z.boolean().optional(),
|
|
26
|
+
resolved_by: user.nullable().optional(),
|
|
27
|
+
});
|
|
28
|
+
const discussionSchema = z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
individual_note: z.boolean(),
|
|
31
|
+
notes: z.array(noteSchema),
|
|
32
|
+
});
|
|
33
|
+
export class GitLabApiError extends Error {
|
|
34
|
+
status;
|
|
35
|
+
constructor(status, message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.status = status;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const PER_PAGE = 100;
|
|
41
|
+
const MAX_NOTE_PAGES = 30;
|
|
42
|
+
const MAX_DISCUSSION_PAGES = 10;
|
|
43
|
+
const MAX_EDITOR_PAGES = 30;
|
|
44
|
+
// Developer: may push to unprotected branches, the nearest to GitHub's write.
|
|
45
|
+
export const DEVELOPER = 30;
|
|
46
|
+
const EDITORS_QUERY = `query($path: ID!, $iid: String!, $after: String) {
|
|
47
|
+
project(fullPath: $path) {
|
|
48
|
+
mergeRequest(iid: $iid) {
|
|
49
|
+
notes(first: 100, after: $after) {
|
|
50
|
+
pageInfo { hasNextPage endCursor }
|
|
51
|
+
nodes { id lastEditedBy { username } }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}`;
|
|
56
|
+
const editorsSchema = z.object({
|
|
57
|
+
project: z.object({
|
|
58
|
+
mergeRequest: z.object({
|
|
59
|
+
notes: z.object({
|
|
60
|
+
pageInfo: z.object({ hasNextPage: z.boolean(), endCursor: z.string().nullable() }),
|
|
61
|
+
nodes: z.array(z.object({
|
|
62
|
+
id: z.string(),
|
|
63
|
+
lastEditedBy: z.object({ username: z.string() }).nullable().optional(),
|
|
64
|
+
})),
|
|
65
|
+
}),
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
// A thin REST and GraphQL client for one project: every response is
|
|
70
|
+
// validated before it reaches the adapter, and errors never echo the token.
|
|
71
|
+
export class GitLabApi {
|
|
72
|
+
project;
|
|
73
|
+
options;
|
|
74
|
+
baseUrl;
|
|
75
|
+
fetchImpl;
|
|
76
|
+
// `project` is the numeric id or the full path ("group/project").
|
|
77
|
+
constructor(project, options) {
|
|
78
|
+
this.project = project;
|
|
79
|
+
this.options = options;
|
|
80
|
+
this.baseUrl = (options.baseUrl ?? "https://gitlab.com/api/v4").replace(/\/+$/, "");
|
|
81
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
82
|
+
}
|
|
83
|
+
async currentUser() {
|
|
84
|
+
return user.parse(await this.send("GET", `${this.baseUrl}/user`, "/user"));
|
|
85
|
+
}
|
|
86
|
+
// The project's full path, which GraphQL takes instead of the id.
|
|
87
|
+
async fullPath() {
|
|
88
|
+
const data = z.object({ path_with_namespace: z.string() }).parse(await this.request("GET", ""));
|
|
89
|
+
return data.path_with_namespace;
|
|
90
|
+
}
|
|
91
|
+
// Whether a push resolves the threads on lines it changed, recording the
|
|
92
|
+
// pusher as the one who resolved them; undefined when GitLab does not say.
|
|
93
|
+
async resolvesOutdatedThreads() {
|
|
94
|
+
const data = z
|
|
95
|
+
.object({ resolve_outdated_diff_discussions: z.boolean().nullish() })
|
|
96
|
+
.parse(await this.request("GET", ""));
|
|
97
|
+
return data.resolve_outdated_diff_discussions ?? undefined;
|
|
98
|
+
}
|
|
99
|
+
async getMergeRequest(iid) {
|
|
100
|
+
return mergeRequestSchema.parse(await this.request("GET", `/merge_requests/${iid}`));
|
|
101
|
+
}
|
|
102
|
+
async listNotes(iid) {
|
|
103
|
+
return this.pages(`/merge_requests/${iid}/notes?sort=asc&order_by=created_at`, noteSchema, MAX_NOTE_PAGES);
|
|
104
|
+
}
|
|
105
|
+
async listDiscussions(iid) {
|
|
106
|
+
return this.pages(`/merge_requests/${iid}/discussions`, discussionSchema, MAX_DISCUSSION_PAGES);
|
|
107
|
+
}
|
|
108
|
+
async createNote(iid, body) {
|
|
109
|
+
await this.request("POST", `/merge_requests/${iid}/notes`, { body });
|
|
110
|
+
}
|
|
111
|
+
async updateNote(iid, noteId, body) {
|
|
112
|
+
await this.request("PUT", `/merge_requests/${iid}/notes/${noteId}`, { body });
|
|
113
|
+
}
|
|
114
|
+
async createDiscussion(iid, body, position) {
|
|
115
|
+
await this.request("POST", `/merge_requests/${iid}/discussions`, { body, position });
|
|
116
|
+
}
|
|
117
|
+
async resolveDiscussion(iid, discussionId) {
|
|
118
|
+
await this.request("PUT", `/merge_requests/${iid}/discussions/${encodeURIComponent(discussionId)}?resolved=true`);
|
|
119
|
+
}
|
|
120
|
+
// The user's role in the project, inherited from groups included; 0 when
|
|
121
|
+
// they are not a member.
|
|
122
|
+
async accessLevel(userId) {
|
|
123
|
+
try {
|
|
124
|
+
const data = z
|
|
125
|
+
.object({ access_level: z.number() })
|
|
126
|
+
.parse(await this.request("GET", `/members/all/${userId}`));
|
|
127
|
+
return data.access_level;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (error instanceof GitLabApiError && error.status === 404)
|
|
131
|
+
return 0;
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async findUser(username) {
|
|
136
|
+
const found = z
|
|
137
|
+
.array(user)
|
|
138
|
+
.parse(await this.send("GET", `${this.baseUrl}/users?username=${encodeURIComponent(username)}`, "/users"));
|
|
139
|
+
return found.find((u) => u.username === username)?.id;
|
|
140
|
+
}
|
|
141
|
+
// Who last edited each note of the merge request, by note id; REST does
|
|
142
|
+
// not say, and a note's updated_at also moves when its thread is resolved.
|
|
143
|
+
async noteEditors(iid) {
|
|
144
|
+
const path = await this.fullPath();
|
|
145
|
+
const editors = new Map();
|
|
146
|
+
let after = null;
|
|
147
|
+
for (let page = 0; page < MAX_EDITOR_PAGES; page += 1) {
|
|
148
|
+
const data = editorsSchema.parse(await this.graphql(EDITORS_QUERY, { path, iid: String(iid), after }));
|
|
149
|
+
const { nodes, pageInfo } = data.project.mergeRequest.notes;
|
|
150
|
+
for (const node of nodes) {
|
|
151
|
+
const id = Number(node.id.slice(node.id.lastIndexOf("/") + 1));
|
|
152
|
+
if (Number.isInteger(id))
|
|
153
|
+
editors.set(id, node.lastEditedBy?.username);
|
|
154
|
+
}
|
|
155
|
+
if (!pageInfo.hasNextPage)
|
|
156
|
+
break;
|
|
157
|
+
after = pageInfo.endCursor;
|
|
158
|
+
}
|
|
159
|
+
return editors;
|
|
160
|
+
}
|
|
161
|
+
async pages(path, schema, maxPages) {
|
|
162
|
+
const items = [];
|
|
163
|
+
const joiner = path.includes("?") ? "&" : "?";
|
|
164
|
+
for (let page = 1; page <= maxPages; page += 1) {
|
|
165
|
+
const batch = z
|
|
166
|
+
.array(schema)
|
|
167
|
+
.parse(await this.request("GET", `${path}${joiner}per_page=${PER_PAGE}&page=${page}`));
|
|
168
|
+
items.push(...batch);
|
|
169
|
+
if (batch.length < PER_PAGE)
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
return items;
|
|
173
|
+
}
|
|
174
|
+
async graphql(query, variables) {
|
|
175
|
+
const url = this.baseUrl.endsWith("/api/v4")
|
|
176
|
+
? `${this.baseUrl.slice(0, -"/v4".length)}/graphql`
|
|
177
|
+
: `${this.baseUrl}/graphql`;
|
|
178
|
+
const result = z
|
|
179
|
+
.object({
|
|
180
|
+
data: z.unknown().optional(),
|
|
181
|
+
errors: z.array(z.object({ message: z.string() })).optional(),
|
|
182
|
+
})
|
|
183
|
+
.parse(await this.send("POST", url, "/graphql", { query, variables }, true));
|
|
184
|
+
if (result.errors?.length) {
|
|
185
|
+
throw new GitLabApiError(200, `GitLab GraphQL failed: ${result.errors.map((e) => e.message).join("; ")}`);
|
|
186
|
+
}
|
|
187
|
+
return result.data;
|
|
188
|
+
}
|
|
189
|
+
request(method, path, body) {
|
|
190
|
+
const project = encodeURIComponent(String(this.project));
|
|
191
|
+
return this.send(method, `${this.baseUrl}/projects/${project}${path}`, path, body);
|
|
192
|
+
}
|
|
193
|
+
// GraphQL queries are safe to repeat, although they are POSTs; REST POSTs
|
|
194
|
+
// create notes and threads, and are not.
|
|
195
|
+
async send(method, url, path, body, idempotent = method !== "POST") {
|
|
196
|
+
const sleep = this.options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
197
|
+
for (let attempt = 1;; attempt += 1) {
|
|
198
|
+
const init = {
|
|
199
|
+
method,
|
|
200
|
+
headers: {
|
|
201
|
+
Accept: "application/json",
|
|
202
|
+
Authorization: `Bearer ${this.options.token}`,
|
|
203
|
+
"User-Agent": "open-cr-agent",
|
|
204
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
205
|
+
},
|
|
206
|
+
signal: AbortSignal.timeout(30_000),
|
|
207
|
+
};
|
|
208
|
+
if (body !== undefined)
|
|
209
|
+
init.body = JSON.stringify(body);
|
|
210
|
+
let response;
|
|
211
|
+
try {
|
|
212
|
+
response = await this.fetchImpl(url, init);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
const next = retryDecision(method, idempotent, "network_error", attempt);
|
|
216
|
+
if (!next.retry)
|
|
217
|
+
throw error;
|
|
218
|
+
await sleep(next.waitMs);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (response.ok)
|
|
222
|
+
return response.status === 204 ? undefined : response.json();
|
|
223
|
+
const detail = (await response.text().catch(() => "")).slice(0, 500);
|
|
224
|
+
const next = retryDecision(method, idempotent, { status: response.status, headers: response.headers, body: detail }, attempt);
|
|
225
|
+
if (next.retry) {
|
|
226
|
+
await sleep(next.waitMs);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
throw new GitLabApiError(response.status, `GitLab ${method} ${path.split("?")[0]} failed with ${response.status}: ${detail}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=client.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { GitLabAdapter } from "./adapter.js";
|
|
3
|
+
import { GitLabApi } from "./client.js";
|
|
4
|
+
const optionsSchema = z.object({
|
|
5
|
+
// The project's numeric id or full path ("group/project").
|
|
6
|
+
project: z.union([z.number().int().positive(), z.string().min(1)]),
|
|
7
|
+
iid: z.number().int().positive(),
|
|
8
|
+
token: z.string().min(1),
|
|
9
|
+
apiUrl: z.string().url().optional(),
|
|
10
|
+
fetch: z.custom((value) => typeof value === "function").optional(),
|
|
11
|
+
code: z.custom((value) => typeof value === "object" &&
|
|
12
|
+
value !== null &&
|
|
13
|
+
["getDiff", "readFile", "searchCode"].every((m) => typeof value[m] === "function"), "code must provide getDiff, readFile and searchCode"),
|
|
14
|
+
snapshot: z
|
|
15
|
+
.custom((value) => typeof value === "object" && value !== null && "diff_refs" in value)
|
|
16
|
+
.optional(),
|
|
17
|
+
history: z
|
|
18
|
+
.custom((value) => typeof value === "object" &&
|
|
19
|
+
value !== null &&
|
|
20
|
+
typeof value.filesChangedSince === "function", "history must provide filesChangedSince")
|
|
21
|
+
.optional(),
|
|
22
|
+
});
|
|
23
|
+
export const gitlabPlugin = {
|
|
24
|
+
name: "vcs-gitlab",
|
|
25
|
+
configure(ctx) {
|
|
26
|
+
ctx.registerVcs("gitlab", (raw) => {
|
|
27
|
+
const options = optionsSchema.parse(raw);
|
|
28
|
+
const api = new GitLabApi(options.project, {
|
|
29
|
+
token: options.token,
|
|
30
|
+
...(options.apiUrl ? { baseUrl: options.apiUrl } : {}),
|
|
31
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
32
|
+
});
|
|
33
|
+
return new GitLabAdapter({
|
|
34
|
+
iid: options.iid,
|
|
35
|
+
api,
|
|
36
|
+
code: options.code,
|
|
37
|
+
...(options.history ? { history: options.history } : {}),
|
|
38
|
+
...(options.snapshot ? { snapshot: options.snapshot } : {}),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=plugin.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-cr-agent/vcs-gitlab",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "GitLab merge request adapter for Open-CR-Agent",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"code-review",
|
|
7
|
+
"gitlab",
|
|
8
|
+
"merge-request"
|
|
9
|
+
],
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"homepage": "https://ocra.majincheng.com",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/jma49/Open-CR-Agent.git",
|
|
15
|
+
"directory": "packages/vcs-gitlab"
|
|
16
|
+
},
|
|
17
|
+
"bugs": "https://github.com/jma49/Open-CR-Agent/issues",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.19"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"!dist/**/*.map"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@open-cr-agent/core": "0.1.2",
|
|
34
|
+
"@open-cr-agent/vcs-platform": "0.1.2",
|
|
35
|
+
"zod": "^4.6.5"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|