lens

package
v0.53.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 12 Imported by: 1 module, 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

Overview

Package lens holds each lens's context: the owner's current work, which the note stage drafts beside and the model read reads beside, so both bear on what the owner works on now. A context reader is registered once under its name, as a deliverer is, and config opens one for a lens from its [lens.<lens>.context] table. With no reader opened for a lens, each stage under it runs without a context.

Index

Constants

View Source
const Slate = "slate"

Slate is the context reader of a slate tracker: its focus in force and its active initiatives, read under SlateScopes. Each initiative in the list carries its title, summary and pursuits, which is what a prompt quotes, so the reader asks no initiative's own route.

Variables

View Source
var SlateScopes = []string{"slate.records.read"}

SlateScopes is what the slate reader's service client asks for.

Functions

func Names

func Names() []string

Names is each registered context reader's name, in order.

func Register

func Register(name string, r Registration)

Register records that this build carries the context reader called name. Registering a name twice panics, as a duplicate is a build error.

Types

type Context

type Context struct {
	// Focus is where the owner's work leans for a while, and nil where none
	// is in force.
	Focus       *Focus
	Initiatives []Initiative
}

Context is the owner's current work, as a context reader answers it.

func (Context) Text

func (c Context) Text() string

Text is the context as a prompt quotes it, and "" where it holds nothing.

type Focus

type Focus struct {
	Statement string
	Until     string
	Shares    []Share
}

Focus is the statement of where the owner's work leans, the last day it holds, and the share of the work each pursuit it names takes.

type Initiative

type Initiative struct {
	Number   int
	Name     string
	Summary  string
	Pursuits []string
}

Initiative is one body of the owner's work under way.

type Reader

type Reader interface {
	Read(ctx context.Context) (Context, error)
}

Reader reads a lens's context. Beside an error it may answer an older context it read, which Text then quotes.

func Cached

func Cached(reader Reader) Reader

Cached is reader answering each read context again for cacheFor. A failed read answers the last context read beside its error, and answers both again for retryAfter.

type Readers

type Readers map[string]Reader

Readers holds the reader opened for each lens, by the lens's name.

func (Readers) Text

func (r Readers) Text(ctx context.Context, lens string, log *slog.Logger) string

Text is the context of lens as a prompt quotes it, and "" where no reader is opened for lens. A read that fails costs the stage only the context: Text logs why on log and answers what the reader answered beside the failure, the last context it read or none, so the stage runs on.

type Registration

type Registration struct {
	Scopes []string
	Open   func(api string, client *http.Client) Reader
}

Registration is one context reader as this build carries it: the scopes its service client needs, and how a worker opens it on the reader's API.

func Lookup

func Lookup(name string) (Registration, bool)

Lookup is the context reader registered as name.

type Share

type Share struct {
	Pursuit string
	Share   float64
}

Share is one pursuit's share of the work, from 0 to 1.

Directories

Path Synopsis
Package slatestandin is what a stand-in slate answers to the lens's slate reader in a test: a focus naming two pursuits, and two active initiatives.
Package slatestandin is what a stand-in slate answers to the lens's slate reader in a test: a focus naming two pursuits, and two active initiatives.

Jump to

Keyboard shortcuts

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