contexttrace

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const FileName = "context-trace.jsonl"

FileName is the canonical name for the context-trace artifact.

Variables

This section is empty.

Functions

func Now

func Now() string

Now returns the current time formatted for context-trace timestamps.

Types

type Event

type Event struct {
	Type      EventType  `json:"type"`
	Timestamp string     `json:"ts"`
	Source    SourceType `json:"source"`

	// provided: what was loaded
	Team         string   `json:"team,omitempty"`
	Doc          string   `json:"doc,omitempty"`
	Docs         []string `json:"docs,omitempty"`
	Section      string   `json:"section,omitempty"`
	InlineTokens int      `json:"inline_tokens,omitempty"`
	ReadOnDemand bool     `json:"read_on_demand,omitempty"`

	// whisper fields (team-whisper, project-whisper)
	From  string `json:"from,omitempty"`
	Topic string `json:"topic,omitempty"`

	// influenced: what mattered
	Decision string `json:"decision,omitempty"`
	PlanStep int    `json:"plan_step,omitempty"`
}

Event is a single context-trace entry.

func ReadEvents

func ReadEvents(path string) ([]Event, error)

ReadEvents reads all events from a context-trace.jsonl file. Malformed lines are skipped. Returns nil, nil for a missing file.

type EventType

type EventType string

EventType distinguishes what kind of context-trace event this is.

const (
	// EventProvided is emitted when context becomes available to the agent.
	EventProvided EventType = "provided"
	// EventInfluenced is emitted when the agent attributes a decision to specific context.
	EventInfluenced EventType = "influenced"
)

type SourceType

type SourceType string

SourceType identifies where the context came from.

const (
	SourceTeamContext    SourceType = "team-context"
	SourceTeamMemory     SourceType = "team-memory"
	SourceTeamDocs       SourceType = "team-docs"
	SourceProjectConfig  SourceType = "project-config"
	SourceTeamWhisper    SourceType = "team-whisper"
	SourceProjectWhisper SourceType = "project-whisper"
	SourceOnDemand       SourceType = "on-demand"
)

type Writer

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

Writer appends events to a context-trace.jsonl file.

func NewWriter

func NewWriter(sessionDir string) *Writer

NewWriter creates a Writer that appends to context-trace.jsonl in the given session dir.

func (*Writer) Append

func (w *Writer) Append(event Event) error

Append marshals the event to JSON and appends it as a single line. Creates the file if it doesn't exist. Safe for sequential use; not goroutine-safe.

func (*Writer) Path

func (w *Writer) Path() string

Path returns the full path to the context-trace.jsonl file.

Jump to

Keyboard shortcuts

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