Documentation
¶
Overview ¶
Package context provides CONTEXT.md generation for agent onboarding.
Index ¶
- Variables
- func Generate(analysis *docs.RepoAnalysis, history *GitHistory, scanState *state.ScanState, ...) error
- func RenderJSON(analysis *docs.RepoAnalysis, history *GitHistory, scanState *state.ScanState, ...) error
- type AuthorJSON
- type AuthorStats
- type BuildCmdJSON
- type CommitSummary
- type ContextJSON
- type GitHistory
- type HistoryJSON
- type MilestoneJSON
- type PatternJSON
- type TagInfo
- type TechComponentJSON
- type TechDebtJSON
- type WeekActivity
- type WeekJSON
Constants ¶
This section is empty.
Variables ¶
var GitOpener testable.GitOpener = testable.DefaultGitOpener
GitOpener is the opener used to access git repositories in the context package. Defaults to testable.DefaultGitOpener. Tests can replace this to inject mocks.
Functions ¶
func Generate ¶
func Generate(analysis *docs.RepoAnalysis, history *GitHistory, scanState *state.ScanState, w io.Writer) error
Generate writes a CONTEXT.md to w based on analysis, git history, and scan state. scanState may be nil if no previous scan exists.
func RenderJSON ¶ added in v0.6.0
func RenderJSON(analysis *docs.RepoAnalysis, history *GitHistory, scanState *state.ScanState, w interface{ Write([]byte) (int, error) }) error
RenderJSON writes the context analysis as machine-readable JSON.
Types ¶
type AuthorJSON ¶ added in v0.6.0
AuthorJSON is the JSON representation of an author.
type AuthorStats ¶
AuthorStats tracks commit count per contributor.
type BuildCmdJSON ¶ added in v0.6.0
type BuildCmdJSON struct {
Name string `json:"name"`
Command string `json:"command"`
Source string `json:"source,omitempty"`
}
BuildCmdJSON is the JSON representation of a build command.
type CommitSummary ¶
type CommitSummary struct {
Hash string
Message string
Author string
Date time.Time
Files int // number of files changed
IsMerge bool // true if commit has 2+ parents
Tag string // non-empty if commit has a semver tag
}
CommitSummary holds metadata about a single commit.
type ContextJSON ¶ added in v0.6.0
type ContextJSON struct {
Name string `json:"name"`
Language string `json:"language"`
TechStack []TechComponentJSON `json:"tech_stack"`
BuildCmds []BuildCmdJSON `json:"build_commands"`
Patterns []PatternJSON `json:"patterns"`
History *HistoryJSON `json:"history,omitempty"`
TechDebt *TechDebtJSON `json:"tech_debt,omitempty"`
}
ContextJSON is the top-level JSON structure for context --format json output.
type GitHistory ¶
type GitHistory struct {
RecentWeeks []WeekActivity
TopAuthors []AuthorStats
TotalCommits int
Milestones []TagInfo // all version tags, newest first, max 10
}
GitHistory holds aggregated git log analysis.
func AnalyzeHistory ¶
func AnalyzeHistory(repoPath string, weeks int) (*GitHistory, error)
AnalyzeHistory walks the git log and groups commits by week. weeks controls how many weeks of history to include (default: 4).
type HistoryJSON ¶ added in v0.6.0
type HistoryJSON struct {
TotalCommits int `json:"total_commits"`
TopAuthors []AuthorJSON `json:"top_authors"`
Milestones []MilestoneJSON `json:"milestones,omitempty"`
RecentWeeks []WeekJSON `json:"recent_weeks,omitempty"`
}
HistoryJSON is the JSON representation of git history analysis.
type MilestoneJSON ¶ added in v0.6.0
type MilestoneJSON struct {
Name string `json:"name"`
Hash string `json:"hash"`
Date string `json:"date"`
}
MilestoneJSON is the JSON representation of a version tag.
type PatternJSON ¶ added in v0.6.0
PatternJSON is the JSON representation of a detected code pattern.
type TagInfo ¶ added in v0.5.0
type TagInfo struct {
Name string // e.g. "v1.2.0"
Hash string // 8-char short hash
Date time.Time // commit date
}
TagInfo holds metadata about a version tag.
type TechComponentJSON ¶ added in v0.6.0
type TechComponentJSON struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Source string `json:"source,omitempty"`
}
TechComponentJSON is the JSON representation of a tech stack component.
type TechDebtJSON ¶ added in v0.6.0
type TechDebtJSON struct {
SignalCount int `json:"signal_count"`
ByKind map[string]int `json:"by_kind"`
}
TechDebtJSON is the JSON representation of technical debt from scan state.
type WeekActivity ¶
type WeekActivity struct {
WeekStart time.Time
Commits []CommitSummary
Tags []TagInfo // version tags that landed in this week
}
WeekActivity groups commits by ISO week.