board

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package board holds the kanban board model and its markdown wire codec.

The markdown grammar preserves the frozen wire format used by older clients.

Index

Constants

View Source
const (
	PrioHigh   = 1
	PrioMedium = 2
	PrioLow    = 3

	// PrioDefault is the priority a task takes when none is given.
	PrioDefault = PrioLow
)

The priority scale, collapsed to three values by issue #234. The stored representation stays the integer the tasks.prio column has always held: the card renders the digit (spec section 3.4), the board sorts on it, and the frozen markdown and JSON wires carry it. Names are a surface vocabulary, not a storage change.

Variables

View Source
var PrioNames = map[int]string{
	PrioHigh:   "high",
	PrioMedium: "medium",
	PrioLow:    "low",
}

PrioNames maps each priority to its canonical name, low to high urgency.

Statuses lists the valid statuses in canonical column order.

Functions

func ContainsSpace

func ContainsSpace(s string) bool

ContainsSpace reports whether s contains a rune the wire format's token splitter treats as whitespace (JavaScript's \s class). Fields serialized as single tokens (tags) must not contain any.

func IsBlank

func IsBlank(s string) bool

IsBlank reports whether s is empty or holds nothing but runes the wire format's token splitter treats as whitespace. A blank title serializes to a bare "- [ ] " line, which Parse reads back as description text rather than as a task.

func IsSingleEmoji

func IsSingleEmoji(s string) bool

IsSingleEmoji reports whether s is exactly the leading-emoji token the title-line grammar recognizes: one Extended_Pictographic rune plus an optional U+FE0F variation selector. Anything else would not survive a Serialize/Parse round trip as the emoji field.

func LeadingEmoji

func LeadingEmoji(s string) string

LeadingEmoji returns the leading emoji token recognized by the markdown grammar, or an empty string when s does not start with one.

func NormalizePrio

func NormalizePrio(p int) int

NormalizePrio folds any value the three-value scale does not name onto PrioLow. It is the read-side counterpart of the schema v10 migration: a legacy 4 meant low before the collapse and means low after it, and an unset or corrupt value takes the same default a task with no priority takes.

func PrioName

func PrioName(p int) string

PrioName is the canonical name of p, normalized onto the scale first.

func Serialize

func Serialize(b Board) string

Serialize renders a board in canonical markdown form: "# Title", one "## To Do"/"## Doing"/"## Done"/"## Cancelled" section per status, and per task a "- [ ] emoji title !p @due ~E %blocked #tag" line followed by two-space-indented description lines and checklist items. Tasks keep their slice order within each section. The Cancelled section is a phase-3 addition and is written only when it has tasks, so legacy three-section boards stay byte-identical on the wire.

func ValidPrio

func ValidPrio(p int) bool

ValidPrio reports whether p is one of the three priorities.

Types

type Board

type Board struct {
	Title string
	Tasks []Task
}

Board is a titled collection of tasks.

func Parse

func Parse(input string) Board

Parse decodes markdown into a Board. It is content-preserving and infallible: unknown constructs degrade into title/description text rather than errors. IDs are left empty (the wire format carries none); CreatedAt and MovedAt are set to the parse time; Position is the task's 0-based ordinal within its column.

type Check

type Check struct {
	Text string
	Done bool
}

Check is a single checklist item on a task.

type Status

type Status string

Status is a board column: "todo", "doing", "done", or "cancelled".

const (
	StatusTodo      Status = "todo"
	StatusDoing     Status = "doing"
	StatusDone      Status = "done"
	StatusCancelled Status = "cancelled"
)

The valid statuses, in column order.

func (Status) Valid

func (s Status) Valid() bool

Valid reports whether s is one of the known statuses.

type Task

type Task struct {
	ID        string
	Seq       int
	Emoji     string
	Title     string
	Desc      string
	Status    Status
	Blocked   bool
	Prio      int
	Due       string
	Effort    string
	Tags      []string
	Checks    []Check
	Position  int
	CreatedAt time.Time
	MovedAt   time.Time
	UpdatedAt time.Time
}

Task is one card on the board.

Due is "YYYY-MM-DD" or empty; Effort is "S", "M", "L", or empty; Prio is 1..3 - 1 high, 2 medium, 3 low - with 3 the default (a Prio of 3 is omitted from the wire format). Issue #234 collapsed the scale from four values; the wire reader still accepts a legacy !4 and normalizes it to 3, which is what it always meant. Blocked marks a task as blocked and rides the wire as the "%blocked" title-line token (written only when true). Tags are plain ("backend") or scoped ("type::bug"). Position is the 0-based ordinal within the task's column and, like ID, Seq, CreatedAt, MovedAt, and UpdatedAt, is metadata not carried by the wire format. UpdatedAt is the last time any stored field of the task changed, including position; MovedAt only tracks its column. Seq is the task's stable per-board sequence number (#n): assigned once on creation, never reused, 0 when unknown, such as a task parsed from legacy Markdown.

Jump to

Keyboard shortcuts

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