pr

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Overview

Package pr implements AI-powered pull request description generation. It collects completed PM tasks, git diff, and git log since a base ref, then asks the configured provider to write a PR title and markdown body.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(ctx *PRContext) string

BuildPrompt constructs the AI prompt for PR generation.

Types

type PRContext

type PRContext struct {
	// Base is the branch or SHA used as the comparison base.
	Base string
	// HeadSHA is the resolved HEAD SHA at collection time.
	HeadSHA string
	// GitLog is the output of `git log --oneline <base>..HEAD`.
	GitLog string
	// GitDiff is the output of `git diff <base>..HEAD` (possibly truncated).
	GitDiff string
	// CompletedTasks are PM tasks with status == done, collected from the plan.
	CompletedTasks []*pm.Task
	// Goal is the project goal from state.
	Goal string
}

PRContext holds the raw data used to generate a pull request description.

func Collect

func Collect(workDir, base string, completedTasks []*pm.Task, goal string) (*PRContext, error)

Collect gathers git history and plan data needed to generate a PR description. workDir must be the git repository root (or any sub-directory). base is a branch name or SHA; defaults to "main" if empty.

type PRResult

type PRResult struct {
	Title string
	Body  string
}

PRResult holds the generated pull request title and body.

func Generate

func Generate(ctx context.Context, prov provider.Provider, model string, timeout time.Duration, prCtx *PRContext) (*PRResult, error)

Generate calls the provider to generate a PR title and body.

func ParseResponse

func ParseResponse(raw string) *PRResult

ParseResponse extracts the title and body from the raw provider response. It expects the format:

TITLE: <title>

<markdown body>

Jump to

Keyboard shortcuts

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