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(artifacts ReviewArtifacts) string
- func LoadPullRequestTemplate(path string) (string, error)
- func PRCmd() *cobra.Command
- type AgentFindings
- type AgenticReviewer
- type AnalysisAgent
- type I18nAgent
- type I18nResult
- type PullRequestPlan
- type ReviewArtifacts
- type ReviewInput
- type TranslationItem
- 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"}}, "needs_i18n": map[string]interface{}{"type": "boolean"}, "i18n_reason": map[string]interface{}{"type": "string"}, }, "required": []string{ "summary", "code_smells", "security_concerns", "agents_guideline_alerts", "test_recommendations", "documentation_updates", "risk_callouts", "needs_i18n", "i18n_reason", }, "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), }, }, } I18nSchema = &openai.ChatCompletionNewParamsResponseFormatUnion{ OfJSONSchema: &openaiShared.ResponseFormatJSONSchemaParam{ JSONSchema: openaiShared.ResponseFormatJSONSchemaJSONSchemaParam{ Name: "i18n_result", Description: openai.String("Extracted translation keys and values"), Schema: interface{}(map[string]interface{}{ "type": "object", "properties": map[string]interface{}{ "translations": map[string]interface{}{ "type": "array", "items": map[string]interface{}{ "type": "object", "properties": map[string]interface{}{ "key": map[string]interface{}{"type": "string"}, "value_en": map[string]interface{}{"type": "string"}, "value_de": map[string]interface{}{"type": "string"}, }, "required": []string{"key", "value_en", "value_de"}, "additionalProperties": false, }, }, }, "required": []string{"translations"}, "additionalProperties": false, }), Strict: openai.Bool(true), }, }, } )
Functions ¶
func CollectAgentGuidelines ¶
CollectAgentGuidelines aggregates every AGENTS.md file discovered under root.
func FormatFindingsComment ¶
func FormatFindingsComment(artifacts ReviewArtifacts) 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"`
NeedsI18n bool `json:"needs_i18n"`
I18nReason string `json:"i18n_reason"`
}
AgentFindings captures the structured response from the analysis agent. 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 ¶
type AnalysisAgent struct {
// contains filtered or unexported fields
}
AnalysisAgent performs the initial code analysis
func NewAnalysisAgent ¶
func NewAnalysisAgent(runtime *shared.RuntimeContext) *AnalysisAgent
func (*AnalysisAgent) Execute ¶
func (a *AnalysisAgent) Execute(input map[string]string) (string, error)
func (*AnalysisAgent) Name ¶
func (a *AnalysisAgent) Name() string
func (*AnalysisAgent) WaitForResults ¶
func (a *AnalysisAgent) WaitForResults() []string
type I18nAgent ¶ added in v0.8.1
type I18nAgent struct {
// contains filtered or unexported fields
}
I18nAgent automatically generates translations for new user-facing strings
func NewI18nAgent ¶ added in v0.8.1
func NewI18nAgent(runtime *shared.RuntimeContext) *I18nAgent
func (*I18nAgent) WaitForResults ¶ added in v0.8.1
type I18nResult ¶ added in v0.8.1
type I18nResult struct {
Translations []TranslationItem `json:"translations"`
}
type PullRequestPlan ¶
PullRequestPlan stores the generated title and filled template.
type ReviewArtifacts ¶
type ReviewArtifacts struct {
Analysis AgentFindings
Plan PullRequestPlan
I18nFindings *I18nResult
}
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 TranslationItem ¶ added in v0.8.1
type WriterAgent ¶
type WriterAgent struct {
// contains filtered or unexported fields
}
WriterAgent generates the PR description
func NewWriterAgent ¶
func NewWriterAgent(runtime *shared.RuntimeContext) *WriterAgent
func (*WriterAgent) Execute ¶
func (a *WriterAgent) Execute(input map[string]string) (string, error)
func (*WriterAgent) Name ¶
func (a *WriterAgent) Name() string
func (*WriterAgent) WaitForResults ¶
func (a *WriterAgent) WaitForResults() []string