commands

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHelpText

func GetHelpText() string

GetHelpText returns the help message for the bot

func ParseMention

func ParseMention(body string) []string

ParseMention extracts mentions from a comment body

Types

type Command

type Command struct {
	Type      CommandType
	Args      string
	RawText   string
	CommentID int64
	File      string // Optional: file context from review comment
	Line      int    // Optional: line context from review comment
}

Command represents a parsed command from a comment

type CommandContext

type CommandContext struct {
	Ctx                 context.Context
	PRTitle             string
	PRDescription       string
	PRNumber            int
	Repository          string
	CommentBody         string // The original comment from user
	FilePath            string // File path if this is a review comment
	FileLine            int    // Line number if this is a review comment
	CodeContext         string // Surrounding code context
	OriginalIssue       string // The original bot comment that user is replying to
	Session             *state.Session
	ConversationHistory []ConversationMessage // Previous messages in this thread
}

CommandContext contains the context for executing a command

type CommandResult

type CommandResult struct {
	Response      string
	UpdateSession bool
	DismissIssue  bool
	DismissedHash string
	DismissReason string
	TriggerReview bool
}

CommandResult contains the result of executing a command

type CommandType

type CommandType string

CommandType represents the type of command

const (
	CommandExplain    CommandType = "explain"
	CommandSuggestFix CommandType = "suggest_fix"
	CommandIgnore     CommandType = "ignore"
	CommandRegenerate CommandType = "regenerate"
	CommandHelp       CommandType = "help"
	CommandSummarize  CommandType = "summarize"
	CommandUnknown    CommandType = "unknown"
)

type ConversationMessage

type ConversationMessage struct {
	Author string
	Body   string
	IsBot  bool
}

ConversationMessage represents a message in a conversation thread

type Handler

type Handler struct {
	AIClient ai.Client
	Config   *internal.Config
}

Handler handles bot commands

func NewHandler

func NewHandler(aiClient ai.Client, config *internal.Config) *Handler

NewHandler creates a new command handler

func (*Handler) Handle

func (h *Handler) Handle(cmd Command, ctx *CommandContext) (*CommandResult, error)

Handle executes a command and returns the response

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses commands from PR comments

func NewParser

func NewParser(botName string) *Parser

NewParser creates a new command parser

func (*Parser) IsBotMentioned

func (p *Parser) IsBotMentioned(body string) bool

IsBotMentioned checks if the bot is mentioned in the comment

func (*Parser) Parse

func (p *Parser) Parse(body string, commentID int64, file string, lineNum int) []Command

Parse extracts commands from a comment body

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL