Documentation
¶
Overview ¶
Package mrdiscussions implements MCP tools for GitLab merge request discussion operations.
The package wraps the GitLab Discussions API for merge request threads:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
- func FormatListMarkdown(out ListOutput) string
- func FormatNoteMarkdown(n NoteOutput) string
- func FormatOutputMarkdown(d Output) string
- type CreateInput
- type DeleteNoteInput
- type DiffLinePositionInput
- type DiffLineRangeInput
- type DiffPosition
- type GetInput
- type ListInput
- type ListOutput
- type NoteOutput
- type Output
- func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
- func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)
- func Resolve(ctx context.Context, client *gitlabclient.Client, input ResolveInput) (Output, error)
- func ToOutput(d *gl.Discussion, extra toolutil.DiscussionExtra) Output
- type ReplyInput
- type ResolveInput
- type UpdateNoteInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionSpecs ¶
func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
ActionSpecs returns canonical specs for merge request discussion actions.
func DeleteNote ¶
func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
DeleteNote removes a note from a discussion thread.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown renders a page of merge request discussion threads through the same shared renderer, so a thread reads the same whether it was listed or fetched.
func FormatNoteMarkdown ¶
func FormatNoteMarkdown(n NoteOutput) string
FormatNoteMarkdown renders one discussion note as the note card every note tool in the tree renders: the author as a handle, the time, the flags that hold, the resolution state, and the body as quoted prose.
It used to print "- **Resolved**: %v" on every note, resolvable or not, and showed neither the internal flag nor who resolved the thread.
func FormatOutputMarkdown ¶
FormatOutputMarkdown renders one discussion thread through the renderer every discussion family shares: the thread's heading, then each note as a list item naming its author, time and ID, with the body quoted underneath.
Types ¶
type CreateInput ¶
type CreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
Body string `json:"body" jsonschema:"Discussion body,required"`
Position *DiffPosition `json:"position,omitempty" jsonschema:"Diff position for inline comments. Omit for general MR discussions."`
// CommitID anchors the discussion to a specific commit within the MR.
CommitID string `json:"commit_id,omitempty" jsonschema:"SHA of the commit to anchor the discussion to (optional)."`
// CreatedAt backdates the discussion's first note; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 148-byte string literal not displayed */
}
CreateInput defines parameters for creating a discussion (inline or general).
type DeleteNoteInput ¶
type DeleteNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion containing the note,required"`
NoteID int64 `json:"note_id" jsonschema:"ID of the note to delete,required"`
}
DeleteNoteInput defines parameters for deleting a discussion note.
type DiffLinePositionInput ¶
type DiffLinePositionInput struct {
LineCode string `json:"line_code,omitempty" jsonschema:"Line code identifying this line in the diff."`
Type string `` /* 137-byte string literal not displayed */
OldLine int `json:"old_line,omitempty" jsonschema:"Line number in the old file for this endpoint."`
NewLine int `json:"new_line,omitempty" jsonschema:"Line number in the new file for this endpoint."`
}
DiffLinePositionInput mirrors gl.LinePositionOptions: one endpoint of a multi-line diff comment range.
type DiffLineRangeInput ¶
type DiffLineRangeInput struct {
Start *DiffLinePositionInput `json:"start,omitempty" jsonschema:"Start endpoint of a multi-line diff comment range."`
End *DiffLinePositionInput `json:"end,omitempty" jsonschema:"End endpoint of a multi-line diff comment range."`
}
DiffLineRangeInput mirrors gl.LineRangeOptions: the start/end endpoints of a multi-line diff comment position.
type DiffPosition ¶
type DiffPosition struct {
BaseSHA string `json:"base_sha" jsonschema:"Base commit SHA (merge-base),required"`
StartSHA string `json:"start_sha" jsonschema:"SHA of the first commit in the MR,required"`
HeadSHA string `json:"head_sha" jsonschema:"HEAD commit SHA of the MR source branch,required"`
OldPath string `json:"old_path,omitempty" jsonschema:"File path before the change (for modified/deleted files)"`
NewPath string `json:"new_path" jsonschema:"File path after the change,required"`
OldLine int `` /* 199-byte string literal not displayed */
NewLine int `` /* 199-byte string literal not displayed */
PositionType string `` /* 166-byte string literal not displayed */
LineRange *DiffLineRangeInput `json:"line_range,omitempty" jsonschema:"Start/end line range for a multi-line text diff comment."`
Width int `json:"width,omitempty" jsonschema:"Image width in pixels (position_type=image)."`
Height int `json:"height,omitempty" jsonschema:"Image height in pixels (position_type=image)."`
X float64 `json:"x,omitempty" jsonschema:"X coordinate of the comment on the image (position_type=image)."`
Y float64 `json:"y,omitempty" jsonschema:"Y coordinate of the comment on the image (position_type=image)."`
}
DiffPosition defines the location of an inline diff comment. It mirrors gl.PositionOptions in full, supporting both text (line) positions and image (coordinate) positions.
type GetInput ¶
type GetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion,required"`
}
GetInput defines parameters for getting a single discussion.
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
// OrderBy names the column used to order keyset-paginated results.
OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. created_at, updated_at)"`
// Sort selects the sort direction for ordered results.
Sort string `json:"sort,omitempty" jsonschema:"Sort direction (asc or desc)"`
toolutil.PaginationInput
toolutil.KeysetPaginationInput
}
ListInput defines parameters for listing discussions.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Discussions []Output `json:"discussions"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a list of discussions.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List returns a paginated list of discussion threads for a merge request, including all notes within each thread.
type NoteOutput ¶
type NoteOutput toolutil.DiscussionThreadNoteOutput
NoteOutput is a note of a merge request discussion: a type of its own over toolutil.DiscussionThreadNoteOutput, the rich note shape the four REST discussion packages share, whose fields and JSON tags (UpdatedAt with omitempty, Resolved and Resolvable without) are defined there. It is a defined type rather than an alias because the Markdown registry is keyed by type: while the four packages aliased one, the commit discussion card rendered every merge request thread and note, offering commit discussion actions as their next steps, and this package's cards were never served (issue 1291).
func NoteToOutput ¶
func NoteToOutput(n *gl.Note, extra toolutil.NoteExtra) NoteOutput
NoteToOutput converts a GitLab API gl.Note, and what the captured response adds to it, to a NoteOutput: the shared conversion in toolutil.DiscussionThreadNoteOutputFromGitLab, kept under the package's name for its callers and tests.
func Reply ¶
func Reply(ctx context.Context, client *gitlabclient.Client, input ReplyInput) (NoteOutput, error)
Reply adds a reply note to an existing discussion thread on a merge request. Returns the newly created note.
func UpdateNote ¶
func UpdateNote(ctx context.Context, client *gitlabclient.Client, input UpdateNoteInput) (NoteOutput, error)
UpdateNote modifies an existing note within a discussion thread.
type Output ¶
type Output toolutil.DiscussionThreadOutput
Output is a merge request discussion thread: a type of its own over toolutil.DiscussionThreadOutput, the thread shape with full note payloads, for the reason NoteOutput gives.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
Create creates a new discussion on a merge request. When a DiffPosition is provided the discussion is attached as an inline comment on the specified file and line; otherwise a general discussion is created.
func Resolve ¶
func Resolve(ctx context.Context, client *gitlabclient.Client, input ResolveInput) (Output, error)
Resolve resolves or unresolves a discussion thread on a merge request, depending on the Resolved flag in the input.
func ToOutput ¶
func ToOutput(d *gl.Discussion, extra toolutil.DiscussionExtra) Output
ToOutput converts a GitLab API gl.Discussion, and what the captured response adds to it, to an Output, including all notes within the thread.
type ReplyInput ¶
type ReplyInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion to reply to,required"`
Body string `json:"body" jsonschema:"Reply body,required"`
// CreatedAt backdates the reply note; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 142-byte string literal not displayed */
}
ReplyInput defines parameters for replying to an existing discussion.
type ResolveInput ¶
type ResolveInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion to resolve,required"`
Resolved bool `json:"resolved" jsonschema:"True to resolve, false to unresolve,required"`
}
ResolveInput defines parameters for resolving/unresolving a discussion.
type UpdateNoteInput ¶
type UpdateNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
MRIID int64 `json:"merge_request_iid" jsonschema:"Merge request IID (project-scoped, not 'merge_request_id'),required"`
DiscussionID string `json:"discussion_id" jsonschema:"ID of the discussion containing the note,required"`
NoteID int64 `json:"note_id" jsonschema:"ID of the note to update,required"`
Body string `json:"body,omitempty" jsonschema:"New body text (Markdown). Leave empty to keep current body."`
Resolved *bool `json:"resolved,omitempty" jsonschema:"Set to true to resolve, false to unresolve. Omit to leave unchanged."`
// CreatedAt overrides the note's creation timestamp; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 142-byte string literal not displayed */
}
UpdateNoteInput defines parameters for updating a discussion note.