board

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package board handles board discovery, scaffolding, and config.

The board is a "north/" directory inside the user's project repo, anchored by "north/config.yml". It is found by walking up from the current directory, the same way git finds ".git". Tasks live in one of three state folders: drafts/, tasks/, archive/.

lock.go — advisory file lock serialising board mutations.

The lock is a "north/.lock" file created with O_CREATE|O_EXCL and removed on release. It guards the read-allocate-write window of mutating operations (notably the NextID scan), so it is held only for the duration of one mutation. A lock file older than staleAfter is presumed abandoned by a crashed process and is stolen. Stdlib only — no flock, so it behaves the same on every platform git works on.

Index

Constants

View Source
const (
	BoardDirname = "north"
	ConfigName   = "config.yml"

	// TemplateName is the editable body scaffold used by bodyless creates.
	TemplateName = "task-template.md"
	// GitattributesName guards board files against CRLF drift on any clone.
	GitattributesName = ".gitattributes"

	// FormatVersion is the board format this binary reads and writes. Boards
	// stamped with a newer version are refused on load.
	FormatVersion = 1
)
View Source
const DefaultTaskTemplate = `## Summary

## Acceptance Criteria

## Notes

## Changes

## Comments
`

DefaultTaskTemplate is what init scaffolds into north/task-template.md. It is a suggestion, never a schema: North writes it once and never parses it back, and a missing or empty template means new tasks get a blank body — this constant is not a runtime fallback.

View Source
const LockName = ".lock"

LockName is the lock file's name inside the board dir.

Variables

DepsEnforcements lists the levels, loosest first.

Functions

func EnsureUserConfig added in v0.7.0

func EnsureUserConfig(dir string) error

EnsureUserConfig creates dir and scaffolds dir/config.yml with the commented template if the file does not exist. An existing file is left untouched.

func InitBoard

func InitBoard(root string) (string, error)

InitBoard scaffolds a board under root (default cwd): config + state folders. Idempotent — existing files/folders are left untouched. Returns the board dir.

func LocateBoard

func LocateBoard(start string) (string, error)

LocateBoard walks up from start (default cwd) to find the "north/" board dir (the one containing config.yml). Returns NotFound with a hint if none exists.

func Lock added in v0.7.0

func Lock(boardDir string) (func(), error)

Lock takes the advisory board lock and returns a release func. It retries briefly while another process holds the lock, steals locks older than staleAfter, and returns Conflict when the board stays locked past the wait budget.

func NextID

func NextID(board string) (string, error)

NextID returns the next free task id — a bare number, max across all folders + 1 (as a string; ids are never reused).

func Root

func Root(board string) string

Root returns the project repo root that contains the board (north/ parent).

func Slug

func Slug(title string) string

Slug builds a filename-safe slug from a title (Backlog.md-style, dash-separated).

func StateDir

func StateDir(board string, state models.TaskState) string

StateDir returns the absolute folder path for a state within the board.

func TaskFilename

func TaskFilename(taskID, title string) string

TaskFilename is the on-disk filename for a task: "12-add-login.md".

func TaskFiles

func TaskFiles(board string, states ...models.TaskState) ([]string, error)

TaskFiles returns the task Markdown files in the given state folders (all states if none are given), sorted within each folder.

func UserConfigDir added in v0.7.0

func UserConfigDir() (string, error)

UserConfigDir returns the user-level config directory, "~/.north".

func WriteConfig

func WriteConfig(board string, cfg Config) (string, error)

WriteConfig writes config.yml, stamping the current format version when the config carries none. Returns the path.

func WriteGitattributes added in v0.7.0

func WriteGitattributes(board string) error

WriteGitattributes writes the board's .gitattributes ("* text eol=lf"), overwriting. Used by init and `doctor --fix`.

Types

type Config

type Config struct {
	Version         int             `yaml:"version"`
	AutoCommit      bool            `yaml:"auto_commit"`
	DepsEnforcement DepsEnforcement `yaml:"deps_enforcement"`
}

Config holds per-board settings from "north/config.yml".

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the defaults (current format version, auto_commit false, deps validated).

func LoadConfig

func LoadConfig(board string) (Config, error)

LoadConfig reads "north/config.yml" into a Config. A missing file and extra keys are tolerated; malformed YAML is a hard error (a silently ignored typo would silently change behaviour, e.g. turning auto_commit off).

type DepsEnforcement added in v0.7.0

type DepsEnforcement string

DepsEnforcement grades how strictly depends_on is enforced on writes. Enforcement never touches stored data, so levels switch freely.

const (
	// DepsHint never refuses a dependency-related action; it only warns
	// (dangling/forward references, self-refs, cycles, out-of-order moves).
	DepsHint DepsEnforcement = "hint"
	// DepsValidated keeps the graph well-formed — dangling ids, self-refs,
	// and cycles are refused on write, delete heals dependents — while
	// workflow order (finishing with unmet deps) only warns. The default.
	DepsValidated DepsEnforcement = "validated"
	// DepsStrict is validated plus workflow enforcement: moving to done or
	// in_progress with unmet dependencies is refused.
	DepsStrict DepsEnforcement = "strict"
)

func ParseDepsEnforcement added in v0.7.0

func ParseDepsEnforcement(value string) (DepsEnforcement, error)

ParseDepsEnforcement coerces a string to a DepsEnforcement level.

type UserConfig added in v0.7.0

type UserConfig struct {
	TUI struct {
		Theme string `yaml:"theme"`
	} `yaml:"tui"`
}

UserConfig holds user-level (per-user, not per-board) settings read from "~/.north/config.yml". Unlike Config, it is personal preference and never committed to the shared repo.

func DefaultUserConfig added in v0.7.0

func DefaultUserConfig() UserConfig

DefaultUserConfig returns the defaults (theme "default").

func LoadUserConfig added in v0.7.0

func LoadUserConfig(dir string) (UserConfig, error)

LoadUserConfig reads dir/config.yml into a UserConfig. A missing file and unknown keys are tolerated; a read error or malformed YAML returns the defaults alongside the error so callers can fall back and warn — they never block on this file.

Jump to

Keyboard shortcuts

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