context

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Packages context provides functionality for loading and managing .context/ files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTokens

func EstimateTokens(content []byte) int

EstimateTokens provides a rough token count estimate for content. Uses a simple heuristic: ~4 characters per token for English text. This is a conservative estimate for Claude/GPT-style tokenizers.

func EstimateTokensString

func EstimateTokensString(s string) int

EstimateTokensString estimates tokens for a string.

func Exists

func Exists(dir string) bool

Exists checks if a context directory exists.

Types

type Context

type Context struct {
	Dir         string
	Files       []FileInfo
	TotalTokens int
	TotalSize   int64
}

Context represents the loaded context from a .context/ directory.

func Load

func Load(dir string) (*Context, error)

Load reads all context files from the specified directory. If `dir` is empty, it uses the default ".context" directory.

type FileInfo

type FileInfo struct {
	Name    string
	Path    string
	Size    int64
	ModTime time.Time
	Content []byte
	IsEmpty bool
	Tokens  int
	Summary string
}

FileInfo represents metadata about a context file.

type NotFoundError

type NotFoundError struct {
	Dir string
}

NotFoundError is returned when the context directory doesn't exist.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Jump to

Keyboard shortcuts

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