context

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package context provides CONTEXT.md generation for agent onboarding.

Index

Constants

This section is empty.

Variables

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

type AuthorJSON struct {
	Name    string `json:"name"`
	Commits int    `json:"commits"`
}

AuthorJSON is the JSON representation of an author.

type AuthorStats

type AuthorStats struct {
	Name    string
	Commits int
}

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

type PatternJSON struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

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.

type WeekJSON added in v0.6.0

type WeekJSON struct {
	WeekStart string   `json:"week_start"`
	Commits   int      `json:"commits"`
	Tags      []string `json:"tags,omitempty"`
}

WeekJSON is the JSON representation of a week of activity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL