Documentation
¶
Index ¶
- func ExtractOrg(lang Language, name string) string
- func NewModuleID(lang Language, name string) string
- func StreamToCache(cache *Cache, key string, r io.Reader) ([]byte, error)
- func WithCache[T any](cache *Cache, key string, fetch func() (T, error)) (T, error)
- type Builder
- type BuilderConfig
- type Cache
- func (c *Cache) Clear(ctx context.Context) error
- func (c *Cache) Delete(ctx context.Context, key string) error
- func (c *Cache) Get(ctx context.Context, key string) ([]byte, bool)
- func (c *Cache) Prune(ctx context.Context) (int, error)
- func (c *Cache) Set(ctx context.Context, key string, data []byte) error
- func (c *Cache) Stats(ctx context.Context) CacheStats
- type CacheConfig
- type CacheStats
- type CachedBuilder
- type CallbackProgress
- func (cp *CallbackProgress) Complete()
- func (cp *CallbackProgress) Error(repo string, err error)
- func (cp *CallbackProgress) FoundModule(module string)
- func (cp *CallbackProgress) ProcessRepo(repo string)
- func (cp *CallbackProgress) Start(totalOrgs int)
- func (cp *CallbackProgress) StartOrg(org string, repoCount int)
- type Cycle
- type DOTConfig
- type DependencyGraph
- func (g *DependencyGraph) AddModule(module Module)
- func (g *DependencyGraph) AllModules() []Module
- func (g *DependencyGraph) Build(ctx context.Context, portfolio Portfolio) error
- func (g *DependencyGraph) Dependencies(moduleID string) []Module
- func (g *DependencyGraph) Dependents(moduleID string) []Module
- func (g *DependencyGraph) FilterByLanguage(lang Language) Graph
- func (g *DependencyGraph) FilterByOrg(org string) Graph
- func (g *DependencyGraph) GetModule(id string) (*Module, bool)
- func (g *DependencyGraph) ManagedModules() []Module
- func (g *DependencyGraph) Snapshot() *GraphSnapshot
- func (g *DependencyGraph) StaleModules(dependency string, minVersion string) []StaleModule
- func (g *DependencyGraph) Stats() GraphStats
- func (g *DependencyGraph) ToDOT(cfg DOTConfig) string
- func (g *DependencyGraph) ToMermaid(cfg MermaidConfig) string
- func (g *DependencyGraph) UpgradeOrder() (*UpgradeOrder, error)
- func (g *DependencyGraph) Validate() []ValidationIssue
- func (g *DependencyGraph) WriteDOT(w io.Writer, cfg DOTConfig) error
- func (g *DependencyGraph) WriteMermaid(w io.Writer, cfg MermaidConfig) error
- type GoModCache
- type GoModInfo
- func (g *GoModInfo) AllDependencies() []ModuleVersion
- func (g *GoModInfo) DirectDependencies() []ModuleVersion
- func (g *GoModInfo) GetReplacement(path string) (ModuleVersion, bool)
- func (g *GoModInfo) HasLocalReplaces() bool
- func (g *GoModInfo) IsLocalReplace(r ModuleReplace) bool
- func (g *GoModInfo) IsReplaced(path string) bool
- type Graph
- type GraphSnapshot
- type GraphStats
- type Language
- type MermaidConfig
- type Module
- type ModuleRef
- type ModuleReplace
- type ModuleVersion
- type Portfolio
- type Progress
- type ProgressCallback
- type ProgressConfig
- type ProgressEvent
- type ProgressEventType
- type RepoListCache
- type StaleModule
- type UpgradeOrder
- type ValidationIssue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractOrg ¶
ExtractOrg extracts the org from a module name. For Go modules: "github.com/grokify/mogo" -> "github.com/grokify" For npm: "@agentplexus/core" -> "@agentplexus"
func NewModuleID ¶
NewModuleID creates a module ID from language and name.
func StreamToCache ¶
StreamToCache streams reader content to cache.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs a dependency graph from GitHub repositories.
func NewBuilder ¶
NewBuilder creates a new graph builder with GitHub authentication.
func NewBuilderWithConfig ¶
func NewBuilderWithConfig(cfg BuilderConfig) *Builder
NewBuilderWithConfig creates a new graph builder with configuration.
type BuilderConfig ¶
type BuilderConfig struct {
// Token is the GitHub personal access token.
Token string
// MaxRetries is the maximum number of retry attempts for API calls.
// Default is 3.
MaxRetries int
// InitialBackoff is the initial backoff duration for retries.
// Default is 1 second.
InitialBackoff time.Duration
// Cache is an optional cache for API responses.
Cache *Cache
}
BuilderConfig configures the graph builder.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides caching for graph-related data. It uses a simple file-based cache with TTL support.
func NewCache ¶
func NewCache(cfg CacheConfig) (*Cache, error)
NewCache creates a new cache with the given configuration.
type CacheConfig ¶
type CacheConfig struct {
// Dir is the directory for file-based cache. If empty, uses temp dir.
Dir string
// TTL is the time-to-live for cached entries. Default is 1 hour.
TTL time.Duration
// MemoryOnly disables file-based caching.
MemoryOnly bool
}
CacheConfig configures the cache behavior.
type CacheStats ¶
type CacheStats struct {
MemoryEntries int `json:"memoryEntries"`
FileEntries int `json:"fileEntries"`
TotalSizeKB int64 `json:"totalSizeKB"`
}
CacheStats provides statistics about cache usage.
type CachedBuilder ¶
type CachedBuilder struct {
// contains filtered or unexported fields
}
CachedBuilder wraps Builder with caching support.
func NewCachedBuilder ¶
func NewCachedBuilder(token string, cache *Cache) *CachedBuilder
NewCachedBuilder creates a new builder with caching.
func (*CachedBuilder) Build ¶
func (cb *CachedBuilder) Build(ctx context.Context, portfolio Portfolio) (*DependencyGraph, error)
Build constructs a dependency graph with caching.
func (*CachedBuilder) InvalidateGraph ¶
func (cb *CachedBuilder) InvalidateGraph(ctx context.Context, portfolio Portfolio) error
InvalidateGraph removes the cached graph for a portfolio.
type CallbackProgress ¶
type CallbackProgress struct {
// contains filtered or unexported fields
}
CallbackProgress adapts a callback function to the Progress interface.
func NewCallbackProgress ¶
func NewCallbackProgress(callback ProgressCallback) *CallbackProgress
NewCallbackProgress creates a progress reporter that calls a callback.
func (*CallbackProgress) Complete ¶
func (cp *CallbackProgress) Complete()
Complete finishes progress tracking.
func (*CallbackProgress) Error ¶
func (cp *CallbackProgress) Error(repo string, err error)
Error reports an error.
func (*CallbackProgress) FoundModule ¶
func (cp *CallbackProgress) FoundModule(module string)
FoundModule reports a found module.
func (*CallbackProgress) ProcessRepo ¶
func (cp *CallbackProgress) ProcessRepo(repo string)
ProcessRepo reports progress on a repository.
func (*CallbackProgress) Start ¶
func (cp *CallbackProgress) Start(totalOrgs int)
Start begins tracking progress.
func (*CallbackProgress) StartOrg ¶
func (cp *CallbackProgress) StartOrg(org string, repoCount int)
StartOrg begins processing an organization.
type Cycle ¶
type Cycle struct {
Modules []string `json:"modules"`
}
Cycle represents a dependency cycle (should not happen in Go).
type DOTConfig ¶
type DOTConfig struct {
// Title is the graph title.
Title string
// RankDir is the direction of graph layout: "TB" (top-bottom), "LR" (left-right).
RankDir string
// ShowExternal includes external (non-managed) dependencies.
ShowExternal bool
// ShowVersions includes version labels on edges.
ShowVersions bool
// ClusterByOrg groups nodes by organization.
ClusterByOrg bool
// ColorManaged is the color for managed modules.
ColorManaged string
// ColorExternal is the color for external modules.
ColorExternal string
}
DOTConfig configures DOT output generation.
func DefaultDOTConfig ¶
func DefaultDOTConfig() DOTConfig
DefaultDOTConfig returns default DOT configuration.
type DependencyGraph ¶
type DependencyGraph struct {
// contains filtered or unexported fields
}
DependencyGraph is the default implementation of Graph.
func BuildFromSnapshot ¶
func BuildFromSnapshot(snapshot *GraphSnapshot) *DependencyGraph
BuildFromSnapshot reconstructs a graph from a snapshot.
func (*DependencyGraph) AddModule ¶
func (g *DependencyGraph) AddModule(module Module)
AddModule adds a module to the graph.
func (*DependencyGraph) AllModules ¶
func (g *DependencyGraph) AllModules() []Module
AllModules returns all modules in the graph.
func (*DependencyGraph) Build ¶
func (g *DependencyGraph) Build(ctx context.Context, portfolio Portfolio) error
Build constructs the graph from a portfolio configuration. Note: The actual fetching from GitHub is done by the GraphBuilder.
func (*DependencyGraph) Dependencies ¶
func (g *DependencyGraph) Dependencies(moduleID string) []Module
Dependencies returns all modules that the given module depends on.
func (*DependencyGraph) Dependents ¶
func (g *DependencyGraph) Dependents(moduleID string) []Module
Dependents returns all modules that depend on the given module.
func (*DependencyGraph) FilterByLanguage ¶
func (g *DependencyGraph) FilterByLanguage(lang Language) Graph
FilterByLanguage returns a new graph containing only modules of the specified language.
func (*DependencyGraph) FilterByOrg ¶
func (g *DependencyGraph) FilterByOrg(org string) Graph
FilterByOrg returns a new graph containing only modules from the specified org.
func (*DependencyGraph) GetModule ¶
func (g *DependencyGraph) GetModule(id string) (*Module, bool)
GetModule returns a module by ID.
func (*DependencyGraph) ManagedModules ¶
func (g *DependencyGraph) ManagedModules() []Module
ManagedModules returns only managed modules (those in the portfolio).
func (*DependencyGraph) Snapshot ¶
func (g *DependencyGraph) Snapshot() *GraphSnapshot
Snapshot creates a point-in-time snapshot of the graph.
func (*DependencyGraph) StaleModules ¶
func (g *DependencyGraph) StaleModules(dependency string, minVersion string) []StaleModule
StaleModules finds managed modules using outdated versions of a dependency.
func (*DependencyGraph) Stats ¶
func (g *DependencyGraph) Stats() GraphStats
Stats returns statistics about the graph.
func (*DependencyGraph) ToDOT ¶
func (g *DependencyGraph) ToDOT(cfg DOTConfig) string
ToDOT returns the graph as a DOT string.
func (*DependencyGraph) ToMermaid ¶
func (g *DependencyGraph) ToMermaid(cfg MermaidConfig) string
ToMermaid returns the graph as a Mermaid string.
func (*DependencyGraph) UpgradeOrder ¶
func (g *DependencyGraph) UpgradeOrder() (*UpgradeOrder, error)
UpgradeOrder returns modules in topological order for upgrades. Uses Kahn's algorithm for topological sorting. Only includes managed modules.
func (*DependencyGraph) Validate ¶
func (g *DependencyGraph) Validate() []ValidationIssue
Validate checks the graph for issues.
func (*DependencyGraph) WriteDOT ¶
func (g *DependencyGraph) WriteDOT(w io.Writer, cfg DOTConfig) error
WriteDOT writes the graph in DOT format for Graphviz.
func (*DependencyGraph) WriteMermaid ¶
func (g *DependencyGraph) WriteMermaid(w io.Writer, cfg MermaidConfig) error
WriteMermaid writes the graph in Mermaid format.
type GoModCache ¶
type GoModCache struct {
// contains filtered or unexported fields
}
GoModCache provides caching specifically for go.mod files.
func NewGoModCache ¶
func NewGoModCache(cache *Cache) *GoModCache
NewGoModCache creates a cache for go.mod files.
type GoModInfo ¶
type GoModInfo struct {
Module string `json:"module"`
Go string `json:"go"`
Require []ModuleVersion `json:"require,omitempty"`
Replace []ModuleReplace `json:"replace,omitempty"`
Exclude []ModuleVersion `json:"exclude,omitempty"`
}
GoModInfo contains parsed go.mod information.
func ParseGoMod ¶
ParseGoMod parses a go.mod file content and returns structured information.
func (*GoModInfo) AllDependencies ¶
func (g *GoModInfo) AllDependencies() []ModuleVersion
AllDependencies returns all dependencies including indirect ones.
func (*GoModInfo) DirectDependencies ¶
func (g *GoModInfo) DirectDependencies() []ModuleVersion
DirectDependencies returns only the direct (non-indirect) dependencies.
func (*GoModInfo) GetReplacement ¶
func (g *GoModInfo) GetReplacement(path string) (ModuleVersion, bool)
GetReplacement returns the replacement for a module path, if any.
func (*GoModInfo) HasLocalReplaces ¶
HasLocalReplaces checks if the module has any local replace directives.
func (*GoModInfo) IsLocalReplace ¶
func (g *GoModInfo) IsLocalReplace(r ModuleReplace) bool
IsLocalReplace checks if a replace directive points to a local path.
func (*GoModInfo) IsReplaced ¶
IsReplaced checks if a module path is replaced.
type Graph ¶
type Graph interface {
// Build constructs the graph from the portfolio configuration.
Build(ctx context.Context, portfolio Portfolio) error
// AddModule adds a module to the graph.
AddModule(module Module)
// GetModule returns a module by ID.
GetModule(id string) (*Module, bool)
// Dependents returns all modules that depend on the given module.
Dependents(moduleID string) []Module
// Dependencies returns all modules that the given module depends on.
Dependencies(moduleID string) []Module
// UpgradeOrder returns modules in topological order for upgrades.
// Only includes managed modules.
UpgradeOrder() (*UpgradeOrder, error)
// StaleModules finds managed modules using outdated versions of a dependency.
StaleModules(dependency string, minVersion string) []StaleModule
// FilterByOrg returns a new graph containing only modules from the specified org.
FilterByOrg(org string) Graph
// FilterByLanguage returns a new graph containing only modules of the specified language.
FilterByLanguage(lang Language) Graph
// AllModules returns all modules in the graph.
AllModules() []Module
// ManagedModules returns only managed modules (those in the portfolio).
ManagedModules() []Module
// Snapshot creates a point-in-time snapshot of the graph.
Snapshot() *GraphSnapshot
}
Graph is the interface for dependency graph operations.
type GraphSnapshot ¶
type GraphSnapshot struct {
Portfolio Portfolio `json:"portfolio"`
Timestamp string `json:"timestamp"`
Modules map[string]Module `json:"modules"` // keyed by module ID
}
GraphSnapshot represents a point-in-time snapshot of the dependency graph.
type GraphStats ¶
type GraphStats struct {
TotalModules int `json:"totalModules"`
ManagedModules int `json:"managedModules"`
ExternalModules int `json:"externalModules"`
TotalEdges int `json:"totalEdges"`
ByLanguage map[Language]int `json:"byLanguage"`
ByOrg map[string]int `json:"byOrg"`
}
GraphStats contains statistics about the dependency graph.
type Language ¶
type Language string
Language represents the programming language of a module.
func ParseModuleID ¶
ParseModuleID parses a module ID into language and name.
func (Language) ManifestFile ¶
ManifestFile returns the manifest file name for this language.
type MermaidConfig ¶
type MermaidConfig struct {
// Direction is "TB", "BT", "LR", or "RL".
Direction string
// ShowExternal includes external dependencies.
ShowExternal bool
}
MermaidConfig configures Mermaid diagram output.
func DefaultMermaidConfig ¶
func DefaultMermaidConfig() MermaidConfig
DefaultMermaidConfig returns default Mermaid configuration.
type Module ¶
type Module struct {
// ID is a universal identifier: "go:github.com/grokify/mogo" or "npm:@agentplexus/core"
ID string `json:"id"`
// Language of this module
Language Language `json:"language"`
// Name is the module name (e.g., "github.com/grokify/mogo")
Name string `json:"name"`
// Org is the GitHub org (e.g., "github.com/grokify")
Org string `json:"org"`
// Version is the current version tag
Version string `json:"version"`
// Repo is the GitHub repository info (nil for external modules)
Repo *model.Repo `json:"repo,omitempty"`
// IsManaged is true if this module is in the portfolio
IsManaged bool `json:"isManaged"`
// Dependencies are modules this module depends on
Dependencies []ModuleRef `json:"dependencies,omitempty"`
// Dependents are modules that depend on this module
Dependents []ModuleRef `json:"dependents,omitempty"`
}
Module represents a dependency module in the graph.
type ModuleRef ¶
type ModuleRef struct {
ID string `json:"id"`
Version string `json:"version"`
IsManaged bool `json:"isManaged"`
}
ModuleRef is a lightweight reference to a module with version.
type ModuleReplace ¶
type ModuleReplace struct {
Old ModuleVersion `json:"old"`
New ModuleVersion `json:"new"`
}
ModuleReplace represents a replace directive in go.mod.
type ModuleVersion ¶
type ModuleVersion struct {
Path string `json:"path"`
Version string `json:"version"`
Indirect bool `json:"indirect,omitempty"`
}
ModuleVersion represents a module with its version.
type Portfolio ¶
type Portfolio struct {
Name string `json:"name" yaml:"name"`
Orgs []string `json:"orgs" yaml:"orgs"` // ["github.com/grokify", "github.com/agentplexus"]
GraphRepo string `json:"graphRepo" yaml:"graph_repo"` // Where to persist the graph
Languages []string `json:"languages" yaml:"languages"` // ["go", "typescript"]
}
Portfolio represents a collection of GitHub orgs managed together.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress tracks and reports build progress.
func NewProgress ¶
func NewProgress(cfg ProgressConfig) *Progress
NewProgress creates a new progress reporter.
func (*Progress) Complete ¶
func (p *Progress) Complete()
Complete finishes progress tracking and prints summary.
func (*Progress) FoundModule ¶
FoundModule reports that a Go module was found.
func (*Progress) ProcessRepo ¶
ProcessRepo reports progress on processing a repository.
type ProgressCallback ¶
type ProgressCallback func(event ProgressEvent)
ProgressCallback is a function called during graph building for progress updates.
type ProgressConfig ¶
type ProgressConfig struct {
// Writer is where progress is written. Default is os.Stderr.
Writer io.Writer
// Enabled controls whether progress is reported.
Enabled bool
// MinInterval is the minimum time between progress updates.
// Default is 100ms.
MinInterval time.Duration
}
ProgressConfig configures progress reporting.
type ProgressEvent ¶
type ProgressEvent struct {
Type ProgressEventType `json:"type"`
Org string `json:"org,omitempty"`
Repo string `json:"repo,omitempty"`
Module string `json:"module,omitempty"`
Current int `json:"current,omitempty"`
Total int `json:"total,omitempty"`
Error error `json:"error,omitempty"`
}
ProgressEvent represents a progress update during graph building.
type ProgressEventType ¶
type ProgressEventType string
ProgressEventType indicates the type of progress event.
const ( ProgressEventStart ProgressEventType = "start" ProgressEventOrg ProgressEventType = "org" ProgressEventRepo ProgressEventType = "repo" ProgressEventModule ProgressEventType = "module" ProgressEventError ProgressEventType = "error" ProgressEventComplete ProgressEventType = "complete" )
type RepoListCache ¶
type RepoListCache struct {
// contains filtered or unexported fields
}
RepoListCache provides caching for repository listings.
func NewRepoListCache ¶
func NewRepoListCache(cache *Cache) *RepoListCache
NewRepoListCache creates a cache for repo listings.
type StaleModule ¶
type StaleModule struct {
Module Module `json:"module"`
Dependency string `json:"dependency"`
Current string `json:"current"`
Latest string `json:"latest"`
}
StaleModule represents a module using an outdated dependency.
type UpgradeOrder ¶
type UpgradeOrder struct {
Modules []Module `json:"modules"`
Cycles []Cycle `json:"cycles,omitempty"`
}
UpgradeOrder represents the recommended order for upgrading modules.
type ValidationIssue ¶
type ValidationIssue struct {
Type string `json:"type"`
Module string `json:"module"`
Message string `json:"message"`
}
ValidationIssue represents a problem found during graph validation.