context

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool     `yaml:"enabled"`
	ProjectRoot     string   `yaml:"project_root"`
	ContextFiles    []string `yaml:"context_files"`
	AutoLoad        []string `yaml:"auto_load_patterns"`
	ExcludePatterns []string `yaml:"exclude_patterns"`
	MaxContextSize  int      `yaml:"max_context_size"` // in tokens
	IncludeHidden   bool     `yaml:"include_hidden"`
}

Config holds context manager configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

type ContextFile

type ContextFile struct {
	Path      string   `json:"path"`
	Type      FileType `json:"type"`
	Weight    float64  `json:"weight"`     // Priority weight (0.0-1.0)
	Variables []string `json:"variables"`  // Template variables
	MaxTokens int      `json:"max_tokens"` // Max tokens to include
	AutoLoad  bool     `json:"auto_load"`  // Auto-load on startup
	Tags      []string `json:"tags"`       // Category tags
	Content   string   `json:"-"`          // Actual content (not serialized)
	LoadedAt  int64    `json:"loaded_at"`  // When it was last loaded
}

ContextFile represents a context file entry

type ContextSummary

type ContextSummary struct {
	TotalFiles  int            `json:"total_files"`
	TotalSize   int            `json:"total_size"`
	ByType      map[string]int `json:"by_type"`
	ByTag       map[string]int `json:"by_tag"`
	Variables   []string       `json:"variables"`
	ProjectRoot string         `json:"project_root"`
}

ContextSummary provides a summary of loaded context

type FileType

type FileType int

FileType represents the type of context file

const (
	TypeMarkdown FileType = iota
	TypeYAML
	TypeJSON
	TypeText
	TypeCode
)

func (FileType) String added in v0.2.0

func (ft FileType) String() string

String returns the string representation of FileType

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles project context files

func NewManager

func NewManager(projectRoot, configDir string) *Manager

NewManager creates a new context manager

func (*Manager) ExtractVariables

func (m *Manager) ExtractVariables(content string) []string

ExtractVariables extracts template variables from content

func (*Manager) GetLoadedContent

func (m *Manager) GetLoadedContent(path string) string

GetLoadedContent returns the loaded content for a file

func (*Manager) GetSummary

func (m *Manager) GetSummary() *ContextSummary

GetSummary returns a summary of the loaded context

func (*Manager) ListContextFiles

func (m *Manager) ListContextFiles() []*ContextFile

ListContextFiles returns all registered context files

func (*Manager) LoadContext

func (m *Manager) LoadContext(cfg *Config) (string, error)

LoadContext loads all context files for a project

func (*Manager) LoadContextCache

func (m *Manager) LoadContextCache() error

LoadContextCache loads cached context

func (*Manager) RegisterContextFile

func (m *Manager) RegisterContextFile(file *ContextFile)

RegisterContextFile registers a context file manually

func (*Manager) RenderTemplate

func (m *Manager) RenderTemplate(content string, variables map[string]string) string

RenderTemplate renders a template with variables

func (*Manager) SaveContext

func (m *Manager) SaveContext() error

SaveContext saves current context state

Jump to

Keyboard shortcuts

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