work

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 23 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.

README

Work

The Work engine under Planner, Content and Writer: workspaces of typed items, links, stages and saved views, kept in Caster under the contract work/v1. Ported from Basalisk (internal/work, internal/api/work.go, frontend/src/work/agent.ts). The data in Caster is the same, so Basalisk and Surface read and write the same workspaces.

Data

Caster Holds
caster://work/<workspace> The workspace's index: work: v1, workspace, title, app (content, planner, writer), preset, ns, owners, created; the body says what it is. Listing work lists the workspaces.
caster://w-<workspace>/kind.<kind> A kind (YAML): label, icon, stages, fields, sections, children, color. Copied from a preset when the workspace is made.
caster://w-<workspace>/i.<id> An item: front matter (kind, title, stage, fields, parent, children, links, material, published, task, tags, cut, signed) and a Markdown body under the kind's section headings. Unknown keys and headings are kept on write.
caster://w-<workspace>/v.<id> A saved view (YAML): view (board, calendar, outline, canvas, flow), title, kinds, filter, group_by, date_field, root, rel, layout.
caster://w-<workspace>/r.<id>.<n> Round n of feedback on an item.

The module's store (migrations/0001_init.sql) is a working copy of those items, refreshed from Caster at most every 15 s per namespace when a workspace is listed or opened (?refresh=1 forces it), and the owner's draft notes not yet sent. Every write goes to Caster at once, after reading the item again; an edit made on an older revision is never written over the newer one: its changed sections become draft suggestions and the call answers 409.

Caster, Torque and Tether mail are reached through Tether's tools (module/tetherlink), with the settings work.tether_command, or work.tether_url with work.tether_token_file. Long listings the gateway cuts short are read whole (tetherlink.CallAll).

After any write the module publishes work.changed with {workspace, id?, what} (what: workspace, item, view, note, round).

Agent tools

Tool Level
work_list read Workspaces (app narrows), or one workspace's kinds, views and items (kind, stage, include_cut).
work_get read One item: fields, links, text by section, rev, draft notes, last round, sign-off.
work_history read An item's revisions (name), or one revision (rev).
work_note write A draft comment or suggestion; the owner sends the round.
work_space_create, work_space_update write Make a workspace from a preset; rename or archive one.
work_item_create, work_item_update, work_item_stage, work_item_place, work_item_restore write Make, edit (with base_rev), stage (never published), place in the outline, restore.
work_note_update, work_view_save write Edit a draft note; make or change a saved view.
work_item_delete, work_space_delete, work_note_delete confirm Cut an item, take a workspace off the list, delete a draft note. All recoverable in Caster except the draft note.

The agent never sends a round, signs off or publishes: those are the owner's, through the routes below.

HTTP

Basalisk's /api/work/... routes, under the module's prefix: /api/m/work/work/.... A view's client calls the same relative paths Basalisk's frontend/src/api/work.ts did (api.get("work/<ws>")), and gets the same JSON. Errors are {code, message, error} with the status shown.

Route Body Answer
GET work?app=&refresh=1 {workspaces: Workspace[], presets: Preset[], problem?}
POST work {workspace, title, preset, about, template?} 201 {workspace, problem?}
GET work/{ws}?refresh=1 {space: {workspace, kinds, items: Card[], views, default_view}, relations, problem?}; 404
PUT work/{ws} {title?, archived?} {updated: true}
DELETE work/{ws} {deleted: true} (kept in Caster, off the list)
PUT work/{ws}/owners {owners: ["msg://..."]} {ok: true}
GET work/{ws}/log?name=i.<id> {revisions: [{rev, at, title}]}
GET work/{ws}/at?name=&rev= {name, rev, content, title?, stage?, sections?}
POST work/{ws}/items {kind, title?, stage?, parent?, fields?, tags?, links?, sections?} 201 {id}
GET work/{ws}/items/{id} Detail: the card plus ref, sections, order, lead?, notes, rounds, sign_off?, changed_since_round, owners
PUT work/{ws}/items/{id} {base_rev, title?, fields?, sections?, tags?, stage?, material?, published?, links?} {rev}; 409 {conflict: true, rev, suggestions}
PUT work/{ws}/items/{id}/move {key: "stage" or a field, value} {rev}
PUT work/{ws}/items/{id}/place {parent, before, view} {ok: true}
POST work/{ws}/items/{id}/cut, …/restore {ok: true}
POST work/{ws}/items/{id}/torque {task, created} (one Torque task per item)
GET work/{ws}/items/{id}/torque {task: {id, title, status} or null, problem?}
POST work/{ws}/items/{id}/notes {kind, section?, quote?, replace?, text?} the note
PUT work/{ws}/notes/{id} {text?, replace?} {ok: true}
DELETE work/{ws}/notes/{id} {ok: true}
POST work/{ws}/items/{id}/round {round, ref, notes, mailed, not_mailed, commented?}
POST work/{ws}/items/{id}/signoff {anyway?} {at, rev, digest, pinned?, round?, stage?, mailed, not_mailed, problem?}; 409 {open, round}
DELETE work/{ws}/items/{id}/signoff {ok: true}
POST work/{ws}/views view keys {id, rev}
PUT work/{ws}/views/{id} view keys (null takes one out) {id, rev}
PUT work/{ws}/views/{id}/layout {cards?, stacks?, notes?} by id (null takes one out) {rev}

The shapes (Workspace, Card, Detail, Kind, View, Preset, the layout) are the Go types in store.go, contract.go, presets.go and layout.go; their JSON is Basalisk's.

Views

Three windows, one component (work/main, web/index.tsx), each opened on its preset's app: work (Planner), work.content (Content) and work.writer (Writer), in the Apps menu. Ported from Basalisk's frontend/src/work.

  • The app's workspaces, and New workspace (from a preset, and a template where the preset has them).
  • A workspace opened on its saved views, switched in the header, and a view added from it: board (columns by stage, kind or an enum field; drag a card to another column), outline (the children tree; drag before, after or into a row), calendar (month or week by a date field; drag to a day or to No date), canvas (cards, stacks bound to a stage or a parent, free notes; pan and zoom) and flow (links as edges; drag from a node's dot to link, Delete to unlink; lanes; tidy).
  • An item's detail beside the view: title, stage, fields by type, sections edited in place (a newer revision becomes suggestions, answered 409), tags, Send to Torque and its status, links both ways, material by reference, the publication log, the review (draft notes, Send round, rounds and answers, sign-off) and the revisions with a word diff.

What is in front is kept in the window's args (workspace, view, item) and reported to the desk, so Describe and the work slot see work:<workspace> or work:<workspace>/<id>. The views refresh on work.changed; they do not poll.

Command Args
work.open, work.content, work.writer workspace?, item? Open Planner, Content or Writer: on its list, or on a workspace (a window of its own, keyed by the slug) and an item in it

Not ported from Basalisk: picking material from the Fragments Engine library (paste the reference instead), Cite chips for references (shown as text or a link), and the detail's 30 s look for a team's answer to a round (it is read again on work.changed and when reopened). The flow draws with a small renderer of its own: a module cannot import the Diagram module's.

Documentation

Overview

Package work is the Work module: the Work engine (README.md) of typed items, links and saved views kept in Caster under the contract work/v1, with three apps as presets over it (Content, Planner, Writer). A workspace's index is in the namespace "work"; its kinds, items and views are in its own namespace, w-<workspace>. Caster and Torque are reached through Tether's tools (module/tetherlink).

Ported from Basalisk (internal/work, internal/api/work.go, frontend/src/work/agent.ts); the data in Caster is the same, so either reads and writes what the other wrote.

Index

Constants

View Source
const IndexNS = "work"

IndexNS is the namespace that lists the workspaces.

View Source
const RoundFrom = "msg://user/local/operator"

RoundFrom is the address a round's mail goes out from: the owner's, as the feedback is his.

View Source
const StagePublished = "published"

StagePublished is the stage that means it went out; reaching it starts the publication log.

Variables

View Source
var ErrNoCaster = errors.New("Caster is not reachable: set work.tether_command (or work.tether_url) in Settings")

ErrNoCaster says there is no way to reach Caster configured, so nothing can be written.

View Source
var ErrNoTorque = errors.New("torque is not reachable here (no link to Tether)")

ErrNoTorque says Torque cannot be reached (no link to Tether).

View Source
var ErrNotFound = errors.New("there is no such workspace or item")

ErrNotFound says there is no such workspace or item.

View Source
var NoteKinds = []string{"comment", "suggestion"}

NoteKinds a draft note may be.

View Source
var Relations = []string{"contains", "depends-on", "leads-to", "appears-in", "uses", "relates"}

Relations every workspace knows; a kind set may add more.

View Source
var ViewKinds = []string{"board", "calendar", "outline", "canvas", "flow"}

ViewKinds are the views a workspace may hold.

Functions

func ItemName

func ItemName(id string) string

ItemName is an item's name in a workspace's namespace (KindName and ViewName are a kind's and a view's).

func KindName

func KindName(kind string) string

func NS

func NS(workspace string) string

NS is a workspace's namespace.

func NewID

func NewID() string

NewID is a fresh 8-character id.

func Presets

func Presets() map[string]Preset

Presets is every preset by id.

func Ref

func Ref(ns, name string) string

Ref is an item's caster:// reference.

func RoundName

func RoundName(id string, n int) string

RoundName is the name of an item's round n in its workspace's namespace.

func ValidID

func ValidID(s string) bool

ValidID says whether s is an item or view id: 8 of [a-z0-9].

func ValidKind

func ValidKind(s string) bool

ValidKind says whether s may be a kind's name.

func ValidSlug

func ValidSlug(s string) bool

ValidSlug says whether s may be a workspace slug: lowercase letters, digits and '-'.

func ViewName

func ViewName(id string) string

Types

type Bind

type Bind struct {
	Key   string `json:"key" yaml:"key"` // stage | parent
	Value string `json:"value" yaml:"value"`
}

Bind is what a stack sets on a card dropped into it.

type Body

type Body struct {
	Lead     string
	Sections []Section
}

Body is an item's body split on its "## " headings. Text before the first heading and sections with headings the kind does not name are kept as they are.

func ParseBody

func ParseBody(body string) Body

ParseBody splits a body on its "## " headings.

func (Body) Get

func (b Body) Get(name string) string

Get is a section's text (heading matched without case, spaces or dashes).

func (*Body) Put

func (b *Body) Put(name, text string, order []string)

Put sets a section's text, in place when it is there; a new one goes in the order given (the kind's sections) among those it names, else at the end.

func (Body) String

func (b Body) String() string

String is the body again.

type Caller

type Caller interface {
	Call(ctx context.Context, tool string, args map[string]any) ([]byte, error)
}

Caller is what the gateway link offers (link.go, over module/tetherlink). CallAll, when it has it, reads the whole of a result the gateway cut.

type CanvasNote

type CanvasNote struct {
	ID   string  `json:"id" yaml:"id"`
	X    float64 `json:"x" yaml:"x"`
	Y    float64 `json:"y" yaml:"y"`
	Text string  `json:"text" yaml:"text"`
}

CanvasNote is a free note on the canvas.

type Card

type Card struct {
	ID        string         `json:"id"`
	Kind      string         `json:"kind"`
	Title     string         `json:"title"`
	Stage     string         `json:"stage"`
	Fields    map[string]any `json:"fields"`
	Parent    string         `json:"parent,omitempty"`
	Children  []string       `json:"children"`
	Links     []Link         `json:"links"`
	Material  []Material     `json:"material"`
	Published []Published    `json:"published"`
	Task      string         `json:"task,omitempty"`
	Tags      []string       `json:"tags"`
	Cut       bool           `json:"cut,omitempty"`
	Signed    bool           `json:"signed,omitempty"`     // signed off
	StaleSign bool           `json:"stale_sign,omitempty"` // signed off, and its text changed since
	Excerpt   string         `json:"excerpt,omitempty"`
	Words     int            `json:"words"`
	Rev       int            `json:"rev"`
	Updated   string         `json:"updated"`
	Problem   string         `json:"problem,omitempty"`
}

Card is an item as the views show it.

type Caster

type Caster interface {
	// List is every item in a namespace, latest revision each.
	List(ctx context.Context, ns string) ([]Head, error)
	// Get is an item's text at a revision (0 = latest). ok is false when there is no such item.
	Get(ctx context.Context, ns, name string, rev int) (it Item, ok bool, err error)
	// Put makes a new revision of ns/name (none when the content is the same) and returns it.
	Put(ctx context.Context, ns, name, content, title string) (rev int, err error)
	// Log is an item's revisions, newest first.
	Log(ctx context.Context, ns, name string) ([]Revision, error)
}

Caster is where the work items live: the index in namespace "work", each workspace in its own. The store keeps a working copy and writes through this; tests give it a stand-in.

type Conflict

type Conflict struct {
	Rev         int
	Suggestions int
}

Conflict says the item moved on in Caster after the owner began the edit. Nothing was overwritten; the owner's changed sections were kept as suggestions on the newer revision (and any other change as a comment).

func (*Conflict) Error

func (c *Conflict) Error() string

type Detail

type Detail struct {
	Card
	Ref      string            `json:"ref"`
	Sections map[string]string `json:"sections"`
	Order    []string          `json:"order"` // the sections shown: the kind's, then any other heading
	Lead     string            `json:"lead,omitempty"`
	Notes    []Note            `json:"notes"`
	Rounds   []RoundView       `json:"rounds"`              // sent, newest first
	SignOff  *SignedOff        `json:"sign_off,omitempty"`  // the item's sign-off, if any
	Changed  bool              `json:"changed_since_round"` // revised since the last round was sent
	Owners   []string          `json:"owners"`              // the workspace's: who rounds are mailed to
}

Detail is one item opened: its card, its sections and the owner's notes on it.

type Doc

type Doc struct {
	Body  string
	Plain bool
	// contains filtered or unexported fields
}

Doc is an item's text: YAML front matter and a markdown body, or (Plain) a YAML document with no body, as kinds and views are. Keys the app does not know are kept as they are when it writes the item again.

func ParseDoc

func ParseDoc(text string) (*Doc, error)

ParseDoc splits front matter from the body. Text without front matter is all body.

func ParsePlain

func ParsePlain(text string) (*Doc, error)

ParsePlain reads a YAML document (a kind, a view). A leading "---" line is allowed.

func (*Doc) Bool

func (d *Doc) Bool(key string) bool

func (*Doc) Decode

func (d *Doc) Decode(key string, v any) error

Decode reads a key into v (for the structured keys: fields, links, material, published).

func (*Doc) Del

func (d *Doc) Del(key string)

Del takes a key out.

func (*Doc) Has

func (d *Doc) Has(key string) bool

Has says whether the key is there.

func (*Doc) Num

func (d *Doc) Num(key string) float64

func (*Doc) Set

func (d *Doc) Set(key string, v any) error

Set writes a key, in place when it is there, at the end when it is not.

func (*Doc) SetField

func (d *Doc) SetField(key string, v any) error

SetField sets one key of the "fields" mapping, keeping the others as they are (nil takes it out).

func (*Doc) Str

func (d *Doc) Str(key string) string

Str reads a key (as Num, Bool and Strings do for their shapes) ("" or zero when it is absent or of another shape).

func (*Doc) String

func (d *Doc) String() string

String is the item's text again.

func (*Doc) Strings

func (d *Doc) Strings(key string) []string

type Edit

type Edit struct {
	BaseRev  int               `json:"base_rev"`
	Title    *string           `json:"title"`
	Fields   map[string]any    `json:"fields"`
	Sections map[string]string `json:"sections"`
	Tags     *[]string         `json:"tags"`
	// Stage, Material and Published replace the item's value when given.
	Stage     *string      `json:"stage"`
	Material  *[]Material  `json:"material"`
	Published *[]Published `json:"published"`
	// Links replaces the item's typed links (never "contains": that is parent and children).
	Links *[]Link `json:"links"`
}

Edit is the owner's change to an item, made on the revision BaseRev. Nil fields are left alone; Fields sets the keys given (null takes one out).

type ErrOpenNotes

type ErrOpenNotes struct {
	Round, Open int
	Problem     string
}

ErrOpenNotes refuses a sign-off while the last round has notes the team has not answered, or cannot be read (then nothing says its notes were answered).

func (*ErrOpenNotes) Error

func (e *ErrOpenNotes) Error() string

type Field

type Field struct {
	Key     string   `yaml:"key" json:"key"`
	Label   string   `yaml:"label,omitempty" json:"label,omitempty"`
	Type    string   `yaml:"type" json:"type"` // text | number | date | enum | ref | refs | url | bool
	Options []string `yaml:"options,omitempty" json:"options,omitempty"`
}

Field is one typed field of a kind.

type GatewayCaster

type GatewayCaster struct{ Link Caller }

GatewayCaster reaches Caster through the Tether gateway.

func (GatewayCaster) Get

func (g GatewayCaster) Get(ctx context.Context, ns, name string, rev int) (Item, bool, error)

func (GatewayCaster) List

func (g GatewayCaster) List(ctx context.Context, ns string) ([]Head, error)

func (GatewayCaster) Log

func (g GatewayCaster) Log(ctx context.Context, ns, name string) ([]Revision, error)

func (GatewayCaster) Put

func (g GatewayCaster) Put(ctx context.Context, ns, name, content, title string) (int, error)

type GatewayNotifier

type GatewayNotifier struct{ Link Caller }

GatewayNotifier tells the team through the Tether gateway.

func (GatewayNotifier) Comment

func (g GatewayNotifier) Comment(ctx context.Context, task, text string) error

func (GatewayNotifier) Mail

func (g GatewayNotifier) Mail(ctx context.Context, to, subject, body, ref string) error

func (GatewayNotifier) Snap

func (g GatewayNotifier) Snap(ctx context.Context, ref string) (string, error)

Snap pins a ref in CAS.

type Head struct {
	Name    string
	Rev     int
	Title   string
	Updated string
}

Head is a listed item: its name in the namespace and latest revision.

type Item

type Item struct {
	NS      string
	Name    string
	Rev     int
	Title   string
	Content string
}

Item is an item's text at a revision.

type Kind

type Kind struct {
	Kind     string   `yaml:"kind" json:"kind"`
	Label    string   `yaml:"label" json:"label"`
	Plural   string   `yaml:"plural,omitempty" json:"plural,omitempty"`
	Icon     string   `yaml:"icon,omitempty" json:"icon,omitempty"` // a lucide name
	Stages   []string `yaml:"stages" json:"stages"`
	Fields   []Field  `yaml:"fields" json:"fields"`
	Sections []string `yaml:"sections" json:"sections"`
	Children []string `yaml:"children" json:"children"`
	Color    string   `yaml:"color,omitempty" json:"color,omitempty"`
	Rev      int      `yaml:"-" json:"rev"`
	Problem  string   `yaml:"-" json:"problem,omitempty"`
}

Kind is what an item is: data, not code. Shipped in presets and copied into a workspace, where it can be edited.

func (Kind) Field

func (k Kind) Field(key string) (Field, bool)

Field is the kind's field named key.

func (Kind) HasStage

func (k Kind) HasStage(st string) bool

HasStage says whether st is one of the kind's stages.

func (Kind) YAML

func (k Kind) YAML() string

YAML is the kind as its Caster item.

type LayoutPatch

type LayoutPatch struct {
	Cards  map[string]*Pos        `json:"cards"`
	Stacks map[string]*Stack      `json:"stacks"`
	Notes  map[string]*CanvasNote `json:"notes"`
}

LayoutPatch changes a layout by id: a card's place, a stack or a note set (null takes it out). Stacks and notes keep their order; a new one goes at the end.

type Link struct {
	Rel string `yaml:"rel" json:"rel"`
	To  string `yaml:"to" json:"to"`
}

Link is a typed relation from one item to another.

type Material

type Material struct {
	Ref     string `yaml:"ref" json:"ref"`
	Caption string `yaml:"caption,omitempty" json:"caption,omitempty"`
}

Material is a reference to something kept elsewhere, never a copy.

type NameKind

type NameKind int

NameKind is what a name in a workspace's namespace holds.

const (
	NameOther NameKind = iota
	NameItem
	NameKindDef
	NameView
	NameRound
)

func ParseName

func ParseName(name string) (NameKind, string)

ParseName reads a name in a workspace's namespace: what it holds, and its id (or kind).

type NewItem

type NewItem struct {
	Kind     string            `json:"kind"`
	Title    string            `json:"title"`
	Stage    string            `json:"stage"`
	Parent   string            `json:"parent"`
	Fields   map[string]any    `json:"fields"`
	Tags     []string          `json:"tags"`
	Links    []Link            `json:"links"`
	Sections map[string]string `json:"sections"`
}

NewItem is what the owner asks to make.

type Note

type Note struct {
	ID        string `json:"id"`
	WS        string `json:"ws"`
	Item      string `json:"item"`
	ItemRev   int    `json:"item_rev,omitempty"`
	Kind      string `json:"kind"`
	Section   string `json:"section,omitempty"`
	Quote     string `json:"quote,omitempty"`
	Replace   string `json:"replace,omitempty"`
	Text      string `json:"text,omitempty"`
	CreatedAt string `json:"created_at"`
}

Note is one piece of the owner's feedback on an item, not yet sent.

type Notifier

type Notifier interface {
	Mail(ctx context.Context, to, subject, body, ref string) error
	Comment(ctx context.Context, task, text string) error
}

Notifier tells the team: a Tether message to each owner, a comment on the item's task.

type Pinner

type Pinner interface {
	Snap(ctx context.Context, ref string) (string, error)
}

Pinner pins an item's revision in CAS (caster_snap).

type Pos

type Pos struct {
	X float64 `json:"x" yaml:"x"`
	Y float64 `json:"y" yaml:"y"`
}

Pos is a place on the canvas.

type Preset

type Preset struct {
	ID    string `json:"id"`
	App   string `json:"app"`
	Label string `json:"label"`
	Kinds []Kind `json:"kinds"`
	Views []View `json:"views"`
	// Templates: starting trees a new workspace can be made with (templates.go).
	Templates []TemplateInfo `json:"templates,omitempty"`
}

Preset is a kind set and the views a new workspace gets.

type Published

type Published struct {
	At    string `yaml:"at" json:"at"`
	Where string `yaml:"where" json:"where"`
	URL   string `yaml:"url,omitempty" json:"url,omitempty"`
	Note  string `yaml:"note,omitempty" json:"note,omitempty"`
}

Published is one entry of an item's publication log.

type Revision

type Revision struct {
	Rev   int    `json:"rev"`
	At    string `json:"at"`
	Title string `json:"title"`
}

Revision is one entry of an item's history.

type RoundNote

type RoundNote struct {
	ID      string `yaml:"id" json:"id"`
	Kind    string `yaml:"kind" json:"kind"`
	Section string `yaml:"section,omitempty" json:"section,omitempty"`
	Quote   string `yaml:"quote,omitempty" json:"quote,omitempty"`
	Replace string `yaml:"replace,omitempty" json:"replace,omitempty"`
	Text    string `yaml:"text,omitempty" json:"text,omitempty"`
	State   string `yaml:"state" json:"state"` // open, done, declined
	Reply   string `yaml:"reply,omitempty" json:"reply,omitempty"`
}

RoundNote is a note as the round item carries it (as in story/v1).

type RoundView

type RoundView struct {
	Round   int         `json:"round"`
	Ref     string      `json:"ref"`
	SentAt  string      `json:"sent_at"`
	ItemRev int         `json:"item_rev"`
	Digest  string      `json:"digest,omitempty"` // of the item's text when sent
	Notes   []RoundNote `json:"notes"`
	Open    int         `json:"open"`
	Problem string      `json:"problem,omitempty"`
}

RoundView is a sent round as the team left it.

type Section

type Section struct {
	Heading string
	Text    string
}

type Sent

type Sent struct {
	Round     int      `json:"round"`
	Ref       string   `json:"ref"`
	Notes     int      `json:"notes"`
	Mailed    []string `json:"mailed"`
	NotMailed []string `json:"not_mailed"` // owners that are not Tether addresses, or whose mail failed
	Commented string   `json:"commented,omitempty"`
}

Sent is what Send round did.

type Signed

type Signed struct {
	SignedOff
	Stage     string   `json:"stage,omitempty"` // the stage it moved to, if it moved
	Mailed    []string `json:"mailed"`
	NotMailed []string `json:"not_mailed"`
	Problem   string   `json:"problem,omitempty"`
}

Signed is what sign-off did.

type SignedOff

type SignedOff struct {
	At     string `yaml:"at" json:"at"`
	Rev    int    `yaml:"rev" json:"rev"`       // the revision that was approved
	Digest string `yaml:"digest" json:"digest"` // of its title and text: a later change makes it stale
	Pinned string `yaml:"pinned,omitempty" json:"pinned,omitempty"`
	Round  int    `yaml:"round,omitempty" json:"round,omitempty"` // the last round sent before it
}

SignedOff is the sign-off an item carries (its `signed` key).

type Space

type Space struct {
	Default   string    `json:"default_view"`
	Workspace Workspace `json:"workspace"`
	Kinds     []Kind    `json:"kinds"`
	Items     []Card    `json:"items"`
	Views     []View    `json:"views"`
}

Space is a workspace opened: its index, kinds, items and views.

type Stack

type Stack struct {
	ID    string   `json:"id" yaml:"id"`
	Title string   `json:"title" yaml:"title"`
	X     float64  `json:"x" yaml:"x"`
	Y     float64  `json:"y" yaml:"y"`
	Items []string `json:"items" yaml:"items"`
	Bind  *Bind    `json:"bind,omitempty" yaml:"bind,omitempty"`
}

Stack is a titled pile of cards.

type Store

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

Store is the working copy of the Work items (the module's own store): a mirror of the Caster items for quick views and reading when Caster is away, and the owner's notes not yet sent. Nothing lives only here once it is in Caster.

Writes go to Caster at once, each after reading the item again: Caster's put has no "only if still at revision N", so a contended item (a parent's children, a view's layout, a card's stage) is re-read and the change applied to what is there, and an edit begun on an older revision does not overwrite the newer one; the owner's text is kept as a suggestion on it instead.

func NewStore

func NewStore(db *sql.DB, caster Caster) *Store

NewStore is the working copy in db (the module's store, migrations/0001_init.sql) over caster. caster may be nil (no way to reach Tether): the copy is then read only and says why.

func (*Store) AddNote

func (s *Store) AddNote(ctx context.Context, ws, id string, n Note) (Note, error)

AddNote puts the owner's (or the agent's, for the owner) note in the item's draft round. A suggestion names the passage it replaces, which must be in that section as it is now.

func (*Store) ApplyTemplate

func (s *Store) ApplyTemplate(ctx context.Context, ws, id string) error

ApplyTemplate makes a template's items in a workspace: the tree (each item in its parent's children, in order), then the links between them.

func (*Store) At

func (s *Store) At(ctx context.Context, ws, name string, rev int) (Item, bool, error)

At is an item at a revision.

func (*Store) Cut

func (s *Store) Cut(ctx context.Context, ws, id string) error

Cut takes an item out of the views (cut: true) and out of its parent's children; it stays in Caster and can be restored.

func (*Store) Detail

func (s *Store) Detail(ctx context.Context, ws, id string) (Detail, bool, error)

Detail is one item from the copy, with its sections and notes.

func (*Store) DropNote

func (s *Store) DropNote(ctx context.Context, ws, id string) error

DropNote takes a note out.

func (*Store) EditItem

func (s *Store) EditItem(ctx context.Context, ws, id string, e Edit) (int, error)

EditItem writes the owner's edit as a new revision, unless the item moved on since BaseRev (then *Conflict).

func (*Store) EditNote

func (s *Store) EditNote(ctx context.Context, ws, id string, text, replace *string) error

EditNote changes a draft note's words.

func (*Store) Kinds

func (s *Store) Kinds(ctx context.Context, ns string) (map[string]Kind, []Kind)

Kinds is a workspace's kinds from the copy, by name.

func (*Store) Log

func (s *Store) Log(ctx context.Context, ws, name string) ([]Revision, error)

Log is an item's history.

func (*Store) MakeItem

func (s *Store) MakeItem(ctx context.Context, ws string, in NewItem) (string, error)

MakeItem makes an item of a kind the workspace has, at the stage given (or the kind's first), and puts it at the end of its parent's children when it has one.

func (*Store) Move

func (s *Store) Move(ctx context.Context, ws, id, key, value string) (int, error)

Move sets one value on an item as it is now: its stage (key "stage") or an enum or date field (a board column, a calendar day). Nothing else of the item changes.

func (*Store) NSOf

func (s *Store) NSOf(ctx context.Context, ws string) string

NSOf is the namespace a workspace's items are in ("" when there is no such workspace).

func (*Store) NewWorkspace

func (s *Store) NewWorkspace(ctx context.Context, slug, title, preset, about string) (string, error)

NewWorkspace makes a workspace from a preset: its kinds and views in its own namespace, then its index in "work" (the index is what makes it exist). Refused when it exists.

func (*Store) Notes

func (s *Store) Notes(ctx context.Context, ws, item string) ([]Note, error)

Notes are the owner's notes on an item, not yet sent.

func (*Store) Open

func (s *Store) Open(ctx context.Context, ws string) (Space, bool, error)

Open is a workspace from the copy. ok is false when there is no such workspace.

func (*Store) PatchLayout

func (s *Store) PatchLayout(ctx context.Context, ws, view string, p LayoutPatch) (int, error)

PatchLayout applies p to a view's layout as it is now: one new revision of the view.

func (*Store) Place

func (s *Store) Place(ctx context.Context, ws, id, parent, before, view string) error

Place puts an item in the outline: under parent (an item id, or "" for the top), before the sibling before (or at the end). Moving it to another parent takes it out of the old parent's children, puts it in the new one's, and sets its parent: each applied to the item as it is now. The top level's order is kept in the outline view's layout (order), when a view is given. A parent must be of a kind that holds the item's kind, and an item cannot go inside itself.

func (*Store) Refresh

func (s *Store) Refresh(ctx context.Context, ns string, force bool) (int, error)

Refresh brings the copy of one namespace up to date with Caster: one listing, and a fetch for each item whose revision moved. At most every 15 s per namespace unless forced.

func (*Store) Restore

func (s *Store) Restore(ctx context.Context, ws, id string) error

Restore puts a cut item back, at the end of its parent's children.

func (*Store) Rounds

func (s *Store) Rounds(ctx context.Context, ws, id string) ([]RoundView, error)

Rounds are an item's sent rounds, newest first (from the copy).

func (*Store) SaveView

func (s *Store) SaveView(ctx context.Context, ws, id string, set map[string]any) (int, error)

SaveView changes a view as it is now: the keys given (view, title, kinds, group_by, date_field, root, rel, filter, layout); other keys stay as they are.

func (*Store) SendRound

func (s *Store) SendRound(ctx context.Context, ws, id string, tell Notifier) (Sent, error)

SendRound writes the item's draft round to Caster and tells the workspace's owners.

func (*Store) SendToTorque

func (s *Store) SendToTorque(ctx context.Context, ws, id string) (task string, created bool, err error)

SendToTorque makes the item's Torque task, or returns the one it already has (created false). The item is read again under the store's lock, so two sends cannot make two tasks.

func (*Store) SetOwners

func (s *Store) SetOwners(ctx context.Context, ws string, owners []string) error

SetOwners sets the Tether addresses a workspace's rounds and sign-offs are mailed to.

func (*Store) SignOff

func (s *Store) SignOff(ctx context.Context, ws, id string, anyway bool, pin Pinner, tell Notifier) (Signed, error)

SignOff approves the item as it is now: the revision and a digest of its text are kept in the item (`signed`), an item at the review stage moves to the next one, the approved revision is pinned in CAS, and the owners are told. When the last round still has open notes, it is refused unless anyway is set. Draft notes are not sent; they stay.

func (*Store) TorqueStatus

func (s *Store) TorqueStatus(ctx context.Context, task string) (TaskStatus, error)

TorqueStatus reads a task's title and status from Torque.

func (*Store) Unsign

func (s *Store) Unsign(ctx context.Context, ws, id string) error

Unsign takes the sign-off off an item (the stage stays).

func (*Store) UpdateWorkspace

func (s *Store) UpdateWorkspace(ctx context.Context, ws string, title *string, archived, deleted *bool) error

UpdateWorkspace retains the index and Caster history even when removed from the list.

func (*Store) Views

func (s *Store) Views(ctx context.Context, ns string) []View

Views is a workspace's saved views from the copy.

func (*Store) Workspaces

func (s *Store) Workspaces(ctx context.Context, app string) ([]Workspace, error)

Workspaces lists the workspaces (for one app when app is set), newest change first.

type TaskStatus

type TaskStatus struct {
	ID     string `json:"id"`
	Title  string `json:"title"`
	Status string `json:"status"`
}

TaskStatus is a Torque task as the detail shows it.

type TemplateInfo

type TemplateInfo struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	About string `json:"about"`
}

TemplateInfo is what the app offers.

func TemplateInfos

func TemplateInfos() []TemplateInfo

TemplateInfos is what the Planner offers.

type View

type View struct {
	ID      string         `yaml:"-" json:"id"`
	View    string         `yaml:"view" json:"view"` // board | calendar | outline | canvas | flow
	Title   string         `yaml:"title" json:"title"`
	Kinds   []string       `yaml:"kinds" json:"kinds"`
	Filter  map[string]any `yaml:"filter,omitempty" json:"filter,omitempty"`
	GroupBy string         `yaml:"group_by,omitempty" json:"group_by,omitempty"`
	DateFld string         `yaml:"date_field,omitempty" json:"date_field,omitempty"`
	Root    string         `yaml:"root,omitempty" json:"root,omitempty"`
	Rel     []string       `yaml:"rel,omitempty" json:"rel,omitempty"`
	Layout  map[string]any `yaml:"layout,omitempty" json:"layout,omitempty"`
	Rev     int            `yaml:"-" json:"rev"`
	Problem string         `yaml:"-" json:"problem,omitempty"`
}

View is a saved way of looking at a workspace; Layout holds a canvas or flow arrangement.

type Workspace

type Workspace struct {
	Archived bool     `json:"archived"`
	Deleted  bool     `json:"deleted"`
	Slug     string   `json:"slug"`
	Title    string   `json:"title"`
	App      string   `json:"app"`
	Preset   string   `json:"preset"`
	NS       string   `json:"ns"`
	Owners   []string `json:"owners"`
	Created  string   `json:"created,omitempty"`
	Body     string   `json:"body"`
	Items    int      `json:"items"`
	Rev      int      `json:"rev"`
	Updated  string   `json:"updated"`
	Problem  string   `json:"problem,omitempty"`
}

Workspace is one body of work, from its index item.

Jump to

Keyboard shortcuts

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