Documentation
¶
Overview ¶
Package aggregate provides multi-project changelog aggregation. It enables combining changelogs from multiple repositories into a unified portfolio view with metrics and dashboard export capabilities.
Index ¶
- Constants
- func DefaultSearchPaths() []string
- func GenerateDashboardJSON(export *DashboardExport, opts DashboardOptions) ([]byte, error)
- func GitHubRepoURL(path string) (string, error)
- func ParseProjectPath(path string) (host, owner, repo, subpath string, err error)
- type CategoryCount
- type DailyCount
- type DashboardExport
- type DashboardOptions
- type DateRange
- type DiscoveryClient
- func (d *DiscoveryClient) DiscoverProjects(ctx context.Context, sources []Source) ([]ProjectRef, error)
- func (d *DiscoveryClient) FetchRemoteChangelog(ctx context.Context, projectPath string) ([]byte, error)
- func (d *DiscoveryClient) FindChangelogPaths(ctx context.Context, owner, repoName string) ([]string, error)
- type DiscoveryOptions
- type DiscoveryResult
- type DiscoveryStats
- type Manifest
- type MetricsOptions
- type MetricsReport
- type Portfolio
- func (p *Portfolio) AllReleases() []ReleaseWithProject
- func (p *Portfolio) FilterByDateRange(start, end string) []ReleaseWithProject
- func (p *Portfolio) GetProject(path string) *ProjectData
- func (p *Portfolio) JSON() ([]byte, error)
- func (p *Portfolio) ProjectNames() []string
- func (p *Portfolio) ProjectPaths() []string
- func (p *Portfolio) Summary() PortfolioSummary
- func (p *Portfolio) WriteFile(path string) error
- type PortfolioSummary
- type ProjectCount
- type ProjectData
- type ProjectMetrics
- type ProjectRef
- type ReleaseWithProject
- type ResolutionSummary
- type ResolvedProject
- type Resolver
- type RollupRules
- type Source
- type SummaryData
- type TimePoint
- type ValidationError
- type ValidationResult
Constants ¶
const GranularityDay = "day"
GranularityDay specifies daily granularity.
const GranularityMonth = "month"
GranularityMonth specifies monthly granularity.
const GranularityWeek = "week"
GranularityWeek specifies weekly granularity.
const SourceTypeOrg = "org"
SourceTypeOrg indicates a GitHub organization source.
const SourceTypeUser = "user"
SourceTypeUser indicates a GitHub user source.
Variables ¶
This section is empty.
Functions ¶
func DefaultSearchPaths ¶
func DefaultSearchPaths() []string
DefaultSearchPaths returns the default directories to search for projects.
func GenerateDashboardJSON ¶
func GenerateDashboardJSON(export *DashboardExport, opts DashboardOptions) ([]byte, error)
GenerateDashboardJSON creates a complete dashforge dashboard definition.
func GitHubRepoURL ¶
GitHubRepoURL returns the GitHub URL for a project path.
func ParseProjectPath ¶
ParseProjectPath parses a project path into its components. Example: "github.com/org/repo/subdir" -> host, owner, repo, subpath
Types ¶
type CategoryCount ¶
CategoryCount pairs a category with its count.
type DailyCount ¶
type DailyCount struct {
Date string `json:"date"` // YYYY-MM-DD
Count int `json:"count"` // Total activity
}
DailyCount represents activity for a single day.
type DashboardExport ¶
type DashboardExport struct {
// Summary metrics widget data
Summary SummaryData `json:"summary"`
// Heatmap data: [[date, count], ...]
HeatmapData [][]any `json:"heatmapData"`
// Time series for charts
ReleaseTrend []map[string]any `json:"releaseTrend"`
CategoryTrend []map[string]any `json:"categoryTrend"`
// Project breakdown table
ProjectTable []map[string]any `json:"projectTable"`
}
DashboardExport contains data formatted for dashboard consumption.
func ExportDashboard ¶
func ExportDashboard(metrics *MetricsReport) (*DashboardExport, error)
ExportDashboard creates dashboard-compatible data from metrics.
func (*DashboardExport) JSON ¶
func (e *DashboardExport) JSON() ([]byte, error)
JSON returns the export as formatted JSON bytes.
type DashboardOptions ¶
type DashboardOptions struct {
Template string // velocity, summary, heatmap
Title string
Theme string // light, dark, auto
DateRange string // last-12-months, last-6-months, ytd, all
ShowFilters bool
}
DashboardOptions configures dashboard generation.
func DefaultDashboardOptions ¶
func DefaultDashboardOptions() DashboardOptions
DefaultDashboardOptions returns default dashboard options.
type DateRange ¶
type DateRange struct {
Start string `json:"start"` // YYYY-MM-DD
End string `json:"end"` // YYYY-MM-DD
}
DateRange represents a time range.
type DiscoveryClient ¶
type DiscoveryClient struct {
// contains filtered or unexported fields
}
DiscoveryClient scans GitHub orgs/users for repos with changelogs.
func NewDiscoveryClient ¶
func NewDiscoveryClient(token string) (*DiscoveryClient, error)
NewDiscoveryClient creates a discovery client with the given token. If token is empty, checks GITHUB_TOKEN environment variable.
func (*DiscoveryClient) DiscoverProjects ¶
func (d *DiscoveryClient) DiscoverProjects(ctx context.Context, sources []Source) ([]ProjectRef, error)
DiscoverProjects scans sources for repos containing CHANGELOG.json. Returns discovered ProjectRefs not already in the manifest.
func (*DiscoveryClient) FetchRemoteChangelog ¶
func (d *DiscoveryClient) FetchRemoteChangelog(ctx context.Context, projectPath string) ([]byte, error)
FetchRemoteChangelog fetches a CHANGELOG.json from a GitHub repository.
func (*DiscoveryClient) FindChangelogPaths ¶
func (d *DiscoveryClient) FindChangelogPaths(ctx context.Context, owner, repoName string) ([]string, error)
FindChangelogPaths searches a repo for CHANGELOG.json files. Returns paths like "github.com/org/repo" or "github.com/org/repo/subdir".
type DiscoveryOptions ¶
type DiscoveryOptions struct {
IncludeArchived bool
IncludeForks bool
MaxReposPerOrg int // 0 = unlimited
}
DiscoveryOptions configures discovery behavior.
func DefaultDiscoveryOptions ¶
func DefaultDiscoveryOptions() DiscoveryOptions
DefaultDiscoveryOptions returns default discovery options.
type DiscoveryResult ¶
type DiscoveryResult struct {
Projects []ProjectRef `json:"projects"`
Statistics DiscoveryStats `json:"statistics"`
}
DiscoveryResult contains discovery results and statistics.
type DiscoveryStats ¶
type DiscoveryStats struct {
SourcesScanned int `json:"sourcesScanned"`
ReposScanned int `json:"reposScanned"`
ReposWithChangelog int `json:"reposWithChangelog"`
ChangelogsFound int `json:"changelogsFound"`
}
DiscoveryStats provides discovery statistics.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Sources []Source `json:"sources,omitempty"`
Projects []ProjectRef `json:"projects"`
Generated *time.Time `json:"generated,omitempty"`
}
Manifest lists projects to aggregate (like go.mod but for changelogs).
func LoadManifest ¶
LoadManifest loads a manifest from a JSON file.
func NewManifest ¶
NewManifest creates a new manifest with the given name.
func ParseManifest ¶
ParseManifest parses a manifest from JSON bytes.
func (*Manifest) AddProject ¶
func (m *Manifest) AddProject(ref ProjectRef) bool
AddProject adds a project to the manifest if not already present. Returns true if added, false if already exists.
func (*Manifest) AddSource ¶
AddSource adds a source to the manifest if not already present. Returns true if added, false if already exists.
func (*Manifest) Validate ¶
func (m *Manifest) Validate() ValidationResult
Validate checks the manifest for errors.
type MetricsOptions ¶
type MetricsOptions struct {
Granularity string // day, week, month
Since time.Time // Filter start
Until time.Time // Filter end
IncludeRollups bool // Include rolled-up counts
}
MetricsOptions configures metrics calculation.
func DefaultMetricsOptions ¶
func DefaultMetricsOptions() MetricsOptions
DefaultMetricsOptions returns default options (daily, last 12 months, with rollups).
type MetricsReport ¶
type MetricsReport struct {
Portfolio string `json:"portfolio"`
DateRange DateRange `json:"dateRange"`
Granularity string `json:"granularity"` // day, week, month
// Summary totals
TotalReleases int `json:"totalReleases"`
TotalEntries int `json:"totalEntries"`
// Raw category counts (all categories)
ByCategory map[string]int `json:"byCategory"`
// Rolled-up counts
ByRollup map[string]int `json:"byRollup,omitempty"`
// Per-project breakdown
ByProject map[string]ProjectMetrics `json:"byProject"`
// Time series (for line/bar charts)
TimeSeries []TimePoint `json:"timeSeries"`
// Daily activity (for heatmap)
DailyActivity []DailyCount `json:"dailyActivity"`
}
MetricsReport contains calculated metrics for a portfolio.
func CalculateMetrics ¶
func CalculateMetrics(portfolio *Portfolio, opts MetricsOptions) (*MetricsReport, error)
CalculateMetrics computes metrics for a portfolio.
func (*MetricsReport) TopCategories ¶
func (r *MetricsReport) TopCategories(n int) []CategoryCount
TopCategories returns the top N categories by count.
func (*MetricsReport) TopProjects ¶
func (r *MetricsReport) TopProjects(n int) []ProjectCount
TopProjects returns the top N projects by entry count.
type Portfolio ¶
type Portfolio struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Projects []ProjectData `json:"projects"`
DateRange DateRange `json:"dateRange"`
GeneratedAt time.Time `json:"generatedAt"`
}
Portfolio represents an aggregated collection of project changelogs.
func LoadPortfolio ¶
func LoadPortfolio(manifest *Manifest, resolved []ResolvedProject) (*Portfolio, error)
LoadPortfolio loads changelogs for resolved projects and creates a portfolio.
func LoadPortfolioFile ¶
LoadPortfolioFile loads a portfolio from a JSON file.
func LoadPortfolioFromPaths ¶
LoadPortfolioFromPaths loads changelogs from explicit file paths.
func ParsePortfolio ¶
ParsePortfolio parses a portfolio from JSON bytes.
func (*Portfolio) AllReleases ¶
func (p *Portfolio) AllReleases() []ReleaseWithProject
AllReleases returns all releases across all projects, sorted by date descending.
func (*Portfolio) FilterByDateRange ¶
func (p *Portfolio) FilterByDateRange(start, end string) []ReleaseWithProject
FilterByDateRange filters releases to those within the given date range.
func (*Portfolio) GetProject ¶
func (p *Portfolio) GetProject(path string) *ProjectData
GetProject returns a project by path, or nil if not found.
func (*Portfolio) ProjectNames ¶
ProjectNames returns the names of all projects.
func (*Portfolio) ProjectPaths ¶
ProjectPaths returns the paths of all projects.
func (*Portfolio) Summary ¶
func (p *Portfolio) Summary() PortfolioSummary
Summary returns aggregate statistics about the portfolio.
type PortfolioSummary ¶
type PortfolioSummary struct {
ProjectCount int `json:"projectCount"`
ReleaseCount int `json:"releaseCount"`
EntryCount int `json:"entryCount"`
ByCategory map[string]int `json:"byCategory"`
DateRange DateRange `json:"dateRange"`
}
PortfolioSummary provides aggregate statistics.
type ProjectCount ¶
type ProjectCount struct {
Path string `json:"path"`
Releases int `json:"releases"`
Entries int `json:"entries"`
}
ProjectCount pairs a project with its counts.
type ProjectData ¶
type ProjectData struct {
Path string `json:"path"`
Name string `json:"name"`
Changelog *changelog.Changelog `json:"changelog"`
}
ProjectData holds a project's changelog data.
type ProjectMetrics ¶
type ProjectMetrics struct {
Releases int `json:"releases"`
Entries int `json:"entries"`
ByCategory map[string]int `json:"byCategory"`
}
ProjectMetrics contains metrics for a single project.
type ProjectRef ¶
type ProjectRef struct {
Path string `json:"path"` // github.com/org/repo or github.com/org/repo/subdir
LocalPath string `json:"localPath,omitempty"` // Override local resolution
Discovered bool `json:"discovered,omitempty"` // Auto-discovered vs manually added
}
ProjectRef references a project containing a changelog.
type ReleaseWithProject ¶
type ReleaseWithProject struct {
ProjectPath string `json:"projectPath"`
ProjectName string `json:"projectName"`
Release *changelog.Release `json:"release"`
}
ReleaseWithProject pairs a release with its project info.
type ResolutionSummary ¶
type ResolutionSummary struct {
TotalCount int `json:"totalCount"`
LocalCount int `json:"localCount"`
RemoteCount int `json:"remoteCount"`
LocalProjects []string `json:"localProjects,omitempty"`
RemoteProjects []string `json:"remoteProjects,omitempty"`
}
ResolutionSummary provides statistics about resolved projects.
type ResolvedProject ¶
type ResolvedProject struct {
Ref ProjectRef // Original project reference
LocalPath string // Absolute path to project directory (empty if not found)
ChangelogPath string // Full path to CHANGELOG.json (empty if not found)
IsLocal bool // true if found locally
NeedsApproval bool // true if remote fetch required
}
ResolvedProject represents a project with resolved local paths.
func FilterLocal ¶
func FilterLocal(resolved []ResolvedProject) []ResolvedProject
FilterLocal returns only projects that were found locally.
func FilterRemote ¶
func FilterRemote(resolved []ResolvedProject) []ResolvedProject
FilterRemote returns only projects that need remote fetch.
type Resolver ¶
type Resolver struct {
SearchPaths []string // Directories to search (e.g., ~/go/src)
}
Resolver resolves Go-style paths to local filesystem locations.
func NewResolver ¶
func NewResolver() *Resolver
NewResolver creates a resolver with default search paths.
func NewResolverWithPaths ¶
NewResolverWithPaths creates a resolver with custom search paths.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(refs []ProjectRef) ([]ResolvedProject, error)
Resolve attempts to resolve all project references to local paths. Projects that cannot be found locally are marked as NeedsApproval.
func (*Resolver) ResolveOne ¶
func (r *Resolver) ResolveOne(ref ProjectRef) ResolvedProject
ResolveOne resolves a single project reference.
func (*Resolver) Summary ¶
func (r *Resolver) Summary(resolved []ResolvedProject) ResolutionSummary
Summary returns a summary of resolution results.
type RollupRules ¶
type RollupRules struct {
Version string `json:"version"`
Rollups map[string][]string `json:"rollups"` // RollupName -> []CategoryNames
}
RollupRules defines how raw categories map to rolled-up groups.
func DefaultRollupRules ¶
func DefaultRollupRules() *RollupRules
DefaultRollupRules returns the embedded default rollup rules. Panics if the embedded rules are invalid (should never happen).
func LoadRollupRules ¶
func LoadRollupRules() (*RollupRules, error)
LoadRollupRules loads the embedded rollup rules.
func ParseRollupRules ¶
func ParseRollupRules(data []byte) (*RollupRules, error)
ParseRollupRules parses rollup rules from JSON bytes.
func (*RollupRules) Apply ¶
func (r *RollupRules) Apply(raw map[string]int) map[string]int
Apply rolls up raw category counts to grouped counts. Any categories not in a rollup group are placed in "Other".
func (*RollupRules) Categories ¶
func (r *RollupRules) Categories(rollupName string) []string
Categories returns all category names that belong to a rollup group.
func (*RollupRules) FindRollup ¶
func (r *RollupRules) FindRollup(category string) string
FindRollup returns the rollup group name for a category. Returns empty string if not found.
func (*RollupRules) RollupNames ¶
func (r *RollupRules) RollupNames() []string
RollupNames returns all rollup group names.
type Source ¶
type Source struct {
Type string `json:"type"` // "org" or "user"
Name string `json:"name"` // GitHub org or username
}
Source defines a GitHub org or user to scan for changelogs.
type SummaryData ¶
type SummaryData struct {
TotalReleases int `json:"totalReleases"`
TotalEntries int `json:"totalEntries"`
ProjectCount int `json:"projectCount"`
DateRange DateRange `json:"dateRange"`
ByRollup map[string]int `json:"byRollup,omitempty"`
}
SummaryData contains high-level summary metrics.
type TimePoint ¶
type TimePoint struct {
Date string `json:"date"` // YYYY-MM-DD, YYYY-MM, or YYYY-Www
Releases int `json:"releases"`
Entries int `json:"entries"`
ByCategory map[string]int `json:"byCategory,omitempty"`
ByRollup map[string]int `json:"byRollup,omitempty"`
}
TimePoint represents metrics at a point in time.
type ValidationError ¶
ValidationError represents a single validation error.
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
Errors []ValidationError `json:"errors,omitempty"`
}
ValidationResult holds manifest validation errors.