Documentation
¶
Overview ¶
Package pr hosts reusable helpers for the pull request workflows that power the `magi pr` command. It includes prompt builders, AGENTS guideline loaders, and the AgenticReviewer used in cmd/pr.go so commands can share hardened logic without reimplementing multi-agent orchestration or sanitization steps.
Index ¶
- Variables
- func CollectAgentGuidelines(root string) (string, error)
- func FormatFindingsComment(findings AgentFindings) string
- func LoadPullRequestTemplate(path string) (string, error)
- type AgentFindings
- type AgenticReviewer
- type AnalysisAgent
- type PullRequestPlan
- type ReviewArtifacts
- type ReviewInput
- type WriterAgent
Constants ¶
This section is empty.
Variables ¶
var ( AnalysisSchema = &openai.ChatCompletionNewParamsResponseFormatUnion{ OfJSONSchema: &openaiShared.ResponseFormatJSONSchemaParam{ JSONSchema: openaiShared.ResponseFormatJSONSchemaJSONSchemaParam{ Name: "analysis_result", Description: openai.String("The analysis result of the PR"), Schema: interface{}(map[string]interface{}{ "type": "object", "properties": map[string]interface{}{ "summary": map[string]interface{}{"type": "string"}, "code_smells": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, "security_concerns": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, "agents_guideline_alerts": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, "test_recommendations": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, "documentation_updates": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, "risk_callouts": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}}, }, "required": []string{ "summary", "code_smells", "security_concerns", "agents_guideline_alerts", "test_recommendations", "documentation_updates", "risk_callouts", }, "additionalProperties": false, }), Strict: openai.Bool(true), }, }, } WriterSchema = &openai.ChatCompletionNewParamsResponseFormatUnion{ OfJSONSchema: &openaiShared.ResponseFormatJSONSchemaParam{ JSONSchema: openaiShared.ResponseFormatJSONSchemaJSONSchemaParam{ Name: "pr_content", Description: openai.String("The PR title and body"), Schema: interface{}(map[string]interface{}{ "type": "object", "properties": map[string]interface{}{ "title": map[string]interface{}{"type": "string"}, "body": map[string]interface{}{"type": "string"}, }, "required": []string{"title", "body"}, "additionalProperties": false, }), Strict: openai.Bool(true), }, }, } )
Functions ¶
func CollectAgentGuidelines ¶
CollectAgentGuidelines aggregates every AGENTS.md file discovered under root.
func FormatFindingsComment ¶
func FormatFindingsComment(findings AgentFindings) string
FormatFindingsComment produces a markdown comment from analysis findings.
func LoadPullRequestTemplate ¶
LoadPullRequestTemplate returns the contents of the GitHub pull request template.
Types ¶
type AgentFindings ¶
type AgentFindings struct {
Summary string `json:"summary"`
CodeSmells []string `json:"code_smells"`
SecurityConcerns []string `json:"security_concerns"`
AgentsGuidelineAlerts []string `json:"agents_guideline_alerts"`
TestRecommendations []string `json:"test_recommendations"`
DocumentationUpdates []string `json:"documentation_updates"`
RiskCallouts []string `json:"risk_callouts"`
}
AgentFindings captures the structured response from the analysis agent.
type AgenticReviewer ¶
type AgenticReviewer struct {
// contains filtered or unexported fields
}
AgenticReviewer orchestrates the agent workflow for PR prep.
func NewAgenticReviewer ¶
func NewAgenticReviewer(runtime *shared.RuntimeContext) *AgenticReviewer
NewAgenticReviewer creates a reviewer bound to the shared runtime context.
func (*AgenticReviewer) Review ¶
func (r *AgenticReviewer) Review(ctx context.Context, input ReviewInput) (*ReviewArtifacts, error)
Review executes the multi-agent workflow and returns structured artifacts.
type AnalysisAgent ¶ added in v0.4.0
type AnalysisAgent struct {
// contains filtered or unexported fields
}
AnalysisAgent performs the initial code analysis
func NewAnalysisAgent ¶ added in v0.4.0
func NewAnalysisAgent(runtime *shared.RuntimeContext) *AnalysisAgent
func (*AnalysisAgent) Execute ¶ added in v0.4.0
func (a *AnalysisAgent) Execute(input map[string]string) (string, error)
func (*AnalysisAgent) Name ¶ added in v0.4.0
func (a *AnalysisAgent) Name() string
func (*AnalysisAgent) WaitForResults ¶ added in v0.4.0
func (a *AnalysisAgent) WaitForResults() []string
type PullRequestPlan ¶
PullRequestPlan stores the generated title and filled template.
type ReviewArtifacts ¶
type ReviewArtifacts struct {
Analysis AgentFindings
Plan PullRequestPlan
}
ReviewArtifacts groups the analysis findings with the final PR plan.
type ReviewInput ¶
type ReviewInput struct {
Diff string
Branch string
RemoteRef string
Guidelines string
AdditionalContext string
Template string
}
ReviewInput encapsulates the information sent to the analysis workflow.
type WriterAgent ¶ added in v0.4.0
type WriterAgent struct {
// contains filtered or unexported fields
}
WriterAgent generates the PR description
func NewWriterAgent ¶ added in v0.4.0
func NewWriterAgent(runtime *shared.RuntimeContext) *WriterAgent
func (*WriterAgent) Execute ¶ added in v0.4.0
func (a *WriterAgent) Execute(input map[string]string) (string, error)
func (*WriterAgent) Name ¶ added in v0.4.0
func (a *WriterAgent) Name() string
func (*WriterAgent) WaitForResults ¶ added in v0.4.0
func (a *WriterAgent) WaitForResults() []string