context

package
v0.0.0-...-4b60cfd Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeContent

func ComposeContent(providers []ContentProvider, templateContent string) string

ComposeContent assembles the editor buffer from provider output and template content. Order: provider outputs (in order, separated by newlines) -> blank line -> template content. Providers that return empty strings or errors are silently skipped.

func LoadManualContexts

func LoadManualContexts(dataDir string) ([]string, error)

LoadManualContexts reads the active manual context names from the state file.

func ResolveActiveContexts

func ResolveActiveContexts(
	resolvers []ContextResolver,
	manualContexts []string,
	store ContextStore,
) ([]entry.ContextRef, []string)

ResolveActiveContexts gathers contexts from resolvers and manual list, deduplicates, and ensures each exists in storage (creating if needed). Returns resolved context refs and a slice of warning messages. Warnings are informational only and never block entry creation.

func SetManualContext

func SetManualContext(dataDir string, name string) error

SetManualContext adds a context name to the active list (idempotent).

func UnsetManualContext

func UnsetManualContext(dataDir string, name string) error

UnsetManualContext removes a context name from the active list.

Types

type CompositeProvider

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

CompositeProvider implements Provider using the local MCP server.

func NewCompositeProvider

func NewCompositeProvider(store storage.Storage) (*CompositeProvider, error)

NewCompositeProvider creates a provider backed by an in-memory MCP server.

func (*CompositeProvider) Filter

Filter implements Provider.Filter.

func (*CompositeProvider) Search

func (p *CompositeProvider) Search(ctx context.Context, query string, limit int) ([]EntryResult, error)

Search implements Provider.Search.

type ContentProvider

type ContentProvider interface {
	Name() string
	Generate() (string, error)
}

ContentProvider generates text for the editor buffer.

func LookupContentProvider

func LookupContentProvider(name string) ContentProvider

LookupContentProvider returns a content provider by name, or nil if unknown.

type ContextResolver

type ContextResolver interface {
	Name() string
	Resolve() ([]string, error)
}

ContextResolver detects contexts from the environment.

func LookupContextResolver

func LookupContextResolver(name string) ContextResolver

LookupContextResolver returns a context resolver by name, or nil if unknown.

type ContextStore

type ContextStore interface {
	GetContextByName(name string) (storage.Context, error)
	CreateContext(c storage.Context) error
}

ContextStore is the subset of storage.Storage needed for context resolution.

type EnrichedContent

type EnrichedContent struct {
	Content         string   `json:"content"`
	SuggestedTags   []string `json:"suggested_tags"`
	Mood            string   `json:"mood,omitempty"`
	FollowUpPrompts []string `json:"follow_up_prompts"`
}

EnrichedContent holds LLM-enriched template output.

type EntryResult

type EntryResult struct {
	ID      string  `json:"id"`
	Preview string  `json:"preview"`
	Date    string  `json:"date"`
	Score   float64 `json:"score"`
}

EntryResult represents a search result from the context provider.

type MCPClient

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

MCPClient wraps an MCP client session for calling tools.

func NewMCPClient

func NewMCPClient(transport mcp.Transport) (*MCPClient, error)

NewMCPClient creates a client connected to the given transport.

func (*MCPClient) CallTool

func (c *MCPClient) CallTool(ctx context.Context, name string, args any) (any, error)

CallTool invokes a tool by name with the given arguments.

func (*MCPClient) Filter

func (c *MCPClient) Filter(ctx context.Context, input mcptools.FilterInput) ([]EntryResult, error)

Filter calls the filter_entries tool.

func (*MCPClient) Search

func (c *MCPClient) Search(ctx context.Context, query string, limit int) ([]EntryResult, error)

Search calls the search_entries tool.

type Provider

type Provider interface {
	// Search performs fuzzy search over diary entries.
	Search(ctx context.Context, query string, limit int) ([]EntryResult, error)

	// Filter retrieves entries matching date/template criteria.
	Filter(ctx context.Context, opts storage.ListOptions) ([]EntryResult, error)
}

Provider defines the interface for context enrichment operations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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