Files
pierre-bot/internal/pierre/resource.go
2026-02-13 17:35:39 +01:00

44 lines
1.4 KiB
Go

package pierre
import (
"context"
"io"
"git.schreifuchs.ch/schreifuchs/pierre-bot/internal/chatter"
)
// Service holds the core collaborators and configuration for Pierre.
// The order of the fields is intentional: configuration fields first (used
// during initialization) followed by the adapters. This prevents accidental
// changes to the serialized layout if encoding/gob or encoding/json is used
// elsewhere in the future.
type Service struct {
maxChunkSize int
guidelines []string
disableComments bool
git GitAdapter
chat ChatAdapter
}
func New(chat ChatAdapter, git GitAdapter, maxChunkSize int, guidelines []string, disableComments bool) *Service {
return &Service{
git: git,
chat: chat,
maxChunkSize: maxChunkSize,
guidelines: guidelines,
disableComments: disableComments,
}
}
type GitAdapter interface {
GetDiff(ctx context.Context, owner, repo string, prID int) (io.ReadCloser, error)
AddComment(ctx context.Context, owner, repo string, prID int, comment Comment) error
GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
GetPRHeadSHA(ctx context.Context, owner, repo string, prID int) (string, error)
}
type ChatAdapter interface {
GenerateStructured(ctx context.Context, messages []chatter.Message, target interface{}) error
GetProviderName() string
}