gitlink-cli/shortcuts/workflow/rules/dispatch.go

32 lines
1.1 KiB
Go

package rules
import "github.com/gitlink-org/gitlink-cli/shortcuts/workflow"
// HealthDispatchRule routes "gitlink-health" skill calls to the correct engine
// based on step name and upstream data shape.
func HealthDispatchRule(upstream map[string]interface{}, stepName string) (*workflow.AIResponse, error) {
// contributor-ranking: from contributor_growth workflow.
if stepName == "contributor-ranking" {
return ContributorRankingRule(upstream, stepName)
}
// repo-health: from multi_repo workflow.
if stepName == "repo-health" {
return HealthReportRule(upstream, stepName)
}
// health-report: from community_ops workflow.
if stepName == "health-report" {
return HealthReportRule(upstream, stepName)
}
// Default: inspect upstream shape to decide.
// If upstream has "members" and "merged-prs" but no "repo-info", it's contributor ranking.
_, hasRepoInfo := upstream["repo-info"]
_, hasMembers := upstream["members"]
if hasMembers && !hasRepoInfo {
return ContributorRankingRule(upstream, stepName)
}
return HealthReportRule(upstream, stepName)
}