Documentation
¶
Overview ¶
Package context provides context window management for AI agents
Index ¶
- func EstimateTokens(content string) int
- func GetRelativePath(base, target string) string
- type ContentInfo
- type ContentThresholds
- type ContentType
- type Manager
- func (m *Manager) CombineContext(pieces []string, maxTotalBytes int64) string
- func (m *Manager) ContentTooLarge(contentType ContentType, content string) bool
- func (m *Manager) GetThresholds() *ContentThresholds
- func (m *Manager) ManageContent(contentType ContentType, path, content string) string
- func (m *Manager) ManageDescription(description string) string
- func (m *Manager) ManageDiff(diff string) string
- func (m *Manager) ManageFile(filePath, content string) string
- func (m *Manager) TruncateContent(content string, maxBytes int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens estimates the number of tokens in content Rough estimate: ~4 characters per token for English text
func GetRelativePath ¶
GetRelativePath returns a relative path from base to target
Types ¶
type ContentInfo ¶
type ContentInfo struct {
Type ContentType
Path string // File path or description
Content string
Size int64 // Size in bytes
Threshold int64 // Size threshold in bytes
}
ContentInfo holds information about content that may be too large
func (*ContentInfo) ShouldUseReference ¶
func (c *ContentInfo) ShouldUseReference() bool
ShouldUseReference returns true if content exceeds its threshold
type ContentThresholds ¶
type ContentThresholds struct {
MaxDescriptionSize project.ByteSize // Default: 250MB
MaxDiffSize project.ByteSize // Default: 250MB
MaxFileSize project.ByteSize // Default: 1MB
}
ContentThresholds defines size limits for different content types
func DefaultThresholds ¶
func DefaultThresholds() *ContentThresholds
DefaultThresholds returns the default content size thresholds
func ThresholdsFromConfig ¶
func ThresholdsFromConfig(cfg *project.Config) *ContentThresholds
ThresholdsFromConfig creates thresholds from project configuration
type ContentType ¶
type ContentType string
ContentType represents the type of content being managed
const ( ContentTypeDescription ContentType = "description" ContentTypeDiff ContentType = "diff" ContentTypeFile ContentType = "file" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles context window management
func NewManager ¶
func NewManager() *Manager
NewManager creates a new context manager with default thresholds
func NewManagerWithConfig ¶
NewManagerWithConfig creates a new context manager with configuration thresholds
func NewManagerWithThresholds ¶
func NewManagerWithThresholds(thresholds *ContentThresholds) *Manager
NewManagerWithThresholds creates a new context manager with custom thresholds
func (*Manager) CombineContext ¶
CombineContext intelligently combines multiple content pieces with size awareness
func (*Manager) ContentTooLarge ¶
func (m *Manager) ContentTooLarge(contentType ContentType, content string) bool
ContentTooLarge returns true if content exceeds its threshold
func (*Manager) GetThresholds ¶
func (m *Manager) GetThresholds() *ContentThresholds
GetThresholds returns the current thresholds
func (*Manager) ManageContent ¶
func (m *Manager) ManageContent(contentType ContentType, path, content string) string
ManageContent checks if content exceeds thresholds and returns either the content or a reference to it
func (*Manager) ManageDescription ¶
ManageDescription manages task description content
func (*Manager) ManageDiff ¶
ManageDiff manages git diff content
func (*Manager) ManageFile ¶
ManageFile manages file content