Documentation
¶
Overview ¶
Package commitdiscussions implements MCP tools for GitLab commit discussion operations.
The package wraps the GitLab Discussions API for commit threads:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
- func DeleteNoteOutput(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) (toolutil.DeleteOutput, error)
- func FormatListMarkdownString(out ListOutput) string
- func FormatMarkdownString(d Output) string
- func FormatNoteMarkdownString(n NoteOutput) string
- type AddNoteInput
- type CreateInput
- type DeleteNoteInput
- type GetInput
- type LinePositionInput
- type LineRangeInput
- type ListInput
- type ListOutput
- type NoteOutput
- type Output
- type PositionInput
- 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 commit discussion actions.
func DeleteNote ¶
func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error
DeleteNote deletes a commit discussion note.
func DeleteNoteOutput ¶
func DeleteNoteOutput(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) (toolutil.DeleteOutput, error)
DeleteNoteOutput deletes a commit discussion note and returns the canonical success message shape.
func FormatListMarkdownString ¶
func FormatListMarkdownString(out ListOutput) string
FormatListMarkdownString renders a list of commit discussion threads as a Markdown table.
func FormatMarkdownString ¶
FormatMarkdownString renders a commit discussion thread with all its notes as Markdown.
func FormatNoteMarkdownString ¶
func FormatNoteMarkdownString(n NoteOutput) string
FormatNoteMarkdownString renders a single commit discussion note as Markdown.
Types ¶
type AddNoteInput ¶
type AddNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,required"`
DiscussionID string `json:"discussion_id" jsonschema:"Discussion ID to reply to,required"`
Body string `json:"body" jsonschema:"Note body (Markdown supported),required"`
// CreatedAt backdates the note; requires admin or project/group owner rights (ISO 8601).
CreatedAt string `` /* 142-byte string literal not displayed */
}
AddNoteInput defines parameters for adding a note to a commit discussion. It mirrors gl.AddCommitDiscussionNoteOptions (body, created_at).
type CreateInput ¶
type CreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,required"`
Body string `json:"body" jsonschema:"Discussion body (Markdown supported),required"`
Position *PositionInput `json:"position,omitempty" jsonschema:"Position for inline diff comments"`
// 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 commit discussion. It mirrors gl.CreateCommitDiscussionOptions (body, position, created_at).
type DeleteNoteInput ¶
type DeleteNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,required"`
DiscussionID string `json:"discussion_id" jsonschema:"Discussion ID,required"`
NoteID int64 `json:"note_id" jsonschema:"Note ID to delete,required"`
}
DeleteNoteInput defines parameters for deleting a commit discussion note.
type GetInput ¶
type GetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,required"`
DiscussionID string `json:"discussion_id" jsonschema:"Discussion ID,required"`
}
GetInput defines parameters for getting a single commit discussion.
type LinePositionInput ¶ added in v2.3.0
type LinePositionInput struct {
LineCode string `json:"line_code,omitempty" jsonschema:"Line code identifying this line in the diff."`
Type string `json:"type,omitempty" jsonschema:"Line type (new, old, or expanded)."`
OldLine int64 `json:"old_line,omitempty" jsonschema:"Line number in the old file for this endpoint."`
NewLine int64 `json:"new_line,omitempty" jsonschema:"Line number in the new file for this endpoint."`
}
LinePositionInput mirrors gl.LinePosition: one endpoint (start or end) of a multi-line diff comment range.
type LineRangeInput ¶ added in v2.3.0
type LineRangeInput struct {
Start *LinePositionInput `json:"start,omitempty" jsonschema:"Start endpoint of a multi-line diff comment range."`
End *LinePositionInput `json:"end,omitempty" jsonschema:"End endpoint of a multi-line diff comment range."`
}
LineRangeInput mirrors gl.LineRange: the start/end endpoints of a multi-line diff comment position.
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,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 commit discussions. It mirrors gl.ListCommitDiscussionsOptions (which embeds gl.ListOptions), exposing keyset pagination (order_by, sort, pagination, page_token) in addition to offset pagination (1:1 audit P3).
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Discussions []Output `json:"discussions"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a list of commit discussions.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List lists commit discussions. It mirrors gl.ListCommitDiscussionsOptions, applying offset and keyset pagination through toolutil.ApplyListOptions.
type NoteOutput ¶
type NoteOutput = toolutil.DiscussionThreadNoteOutput
NoteOutput is an alias of toolutil.DiscussionThreadNoteOutput, the rich note shape used within discussion threads, shared with mrdiscussions. Field layout and JSON tags (including UpdatedAt with omitempty and Resolved/Resolvable without omitempty) are defined in toolutil.
func AddNote ¶
func AddNote(ctx context.Context, client *gitlabclient.Client, input AddNoteInput) (NoteOutput, error)
AddNote adds a note to an existing commit discussion.
func NoteToOutput ¶ added in v2.3.0
func NoteToOutput(n *gl.Note) NoteOutput
NoteToOutput converts a GitLab API gl.Note to a NoteOutput. Per the 1:1 audit policy it surfaces the full author object on the canonical `author` key, additively surfaces the resolved_by / position sub-objects, and mirrors every other gl.Note field. Timestamps are formatted as RFC 3339 strings.
func UpdateNote ¶
func UpdateNote(ctx context.Context, client *gitlabclient.Client, input UpdateNoteInput) (NoteOutput, error)
UpdateNote updates an existing commit discussion note.
type Output ¶
type Output = toolutil.DiscussionThreadOutput
Output is an alias of toolutil.DiscussionThreadOutput, the discussion thread shape with full note payloads, shared with mrdiscussions.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
Create creates a new commit discussion thread.
func ToOutput ¶ added in v2.3.0
func ToOutput(d *gl.Discussion) Output
ToOutput converts a GitLab API gl.Discussion to an Output, including all notes within the thread.
type PositionInput ¶
type PositionInput struct {
BaseSHA string `json:"base_sha" jsonschema:"Base commit SHA,required"`
StartSHA string `json:"start_sha" jsonschema:"Start commit SHA,required"`
HeadSHA string `json:"head_sha" jsonschema:"Head commit SHA,required"`
PositionType string `json:"position_type" jsonschema:"Position type (text or image),required"`
NewPath string `json:"new_path,omitempty" jsonschema:"File path after change"`
NewLine int64 `json:"new_line,omitempty" jsonschema:"Line number after change"`
OldPath string `json:"old_path,omitempty" jsonschema:"File path before change"`
OldLine int64 `json:"old_line,omitempty" jsonschema:"Line number before change"`
LineRange *LineRangeInput `json:"line_range,omitempty" jsonschema:"Start/end line range for a multi-line text diff comment."`
}
PositionInput defines position attributes for inline commit discussions. It mirrors gl.NotePosition in full — the position struct accepted by gl.CreateCommitDiscussionOptions.Position. Commit-thread positions are text (line) positions only; gl.NotePosition has no image (width/height/x/y) fields, so none are surfaced here (1:1 audit: no invented fields).
type UpdateNoteInput ¶
type UpdateNoteInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Commit SHA,required"`
DiscussionID string `json:"discussion_id" jsonschema:"Discussion ID,required"`
NoteID int64 `json:"note_id" jsonschema:"Note ID to update,required"`
Body string `json:"body" jsonschema:"Updated note body,required"`
// 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 commit discussion note. It mirrors gl.UpdateCommitDiscussionNoteOptions (body, created_at).