cliapp

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cliapp implements the kb command-line interface against the local SQLite store. Task ids are stable per-board sequence numbers ("#12", bare "12" works too) with UUIDs still addressable by unique prefix.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProject = errors.New(`no project given: pass -p <name> or --tag project::<name>`)

ErrNoProject is the refusal every mandatory-project path shares. The project is always spelled on the command: there is no ambient default to fall back to, so two shells or two agents on one data directory cannot file a task into each other's project.

Functions

func BackfillProjects

func BackfillProjects(st ProjectBackfiller, user string) (int, error)

BackfillProjects gives every task without exactly one project:: label the invariant it is missing: none becomes project::inbox, several collapse to the first. It is idempotent — a second pass finds nothing to do — and returns the number of tasks it rewrote.

It runs automatically whenever a local store is opened rather than behind an explicit command: the mandatory-project rule is only true if it holds for the tasks that predate it, and OpenLocalStore is the one startup path every local surface already shares (it is where the legacy markdown import lives too). Nothing is written once the board is clean.

func CurrentProjectOf

func CurrentProjectOf(t board.Task) string

CurrentProjectOf returns the single project a task carries, or "" when it carries none or more than one (both of which the caller then replaces).

func OpenLocalStore

func OpenLocalStore(dataDir string, stderr io.Writer) (*store.Store, error)

OpenLocalStore opens the local SQLite store with the same data-directory, secret, and legacy-import behavior used by the task CLI. Other local human interfaces use this rather than quietly inventing a second startup path.

func ProjectTags

func ProjectTags(tags []string, flagValue, current string) ([]string, error)

ProjectTags returns tags carrying exactly one project:: label — the invariant every task-mutating path funnels through, on every surface. The CLI passes its -p value as flagValue; surfaces with their own project argument (the MCP tools, the web API) pass that.

A project:: label spelled directly in --tag is as explicit as -p, and contradicting an explicit -p is an error rather than a silent winner. current is the project the task already has ("" when it has none or when the task is new): editing labels on an existing task keeps it in its project instead of demanding the flag again. A new task with no project anywhere is refused.

func Run

func Run(args []string, stdout, stderr io.Writer) int

Run executes one kb CLI invocation. args starts with the subcommand, e.g. ["add", "Fix bug", "--prio", "2"]. It returns the process exit code: 0 on success, 1 on runtime errors, 2 on usage errors.

func SplitProjectTags

func SplitProjectTags(tags []string) (projects, rest []string)

SplitProjectTags separates the project names a tag list carries from the tags that are not project labels, both in their original order.

func ValidateProjectName

func ValidateProjectName(name string) (string, error)

ValidateProjectName checks a project name by the rule already applied to label values: non-empty, no whitespace, no leading '#'. It additionally rejects "::" so a name can never smuggle a second scope into the label.

Types

type ProjectBackfiller

type ProjectBackfiller interface {
	FilterTasks(user string, f store.TaskFilter) ([]board.Task, error)
	UpdateTask(user, ref string, p store.TaskPatch) (board.Task, error)
}

ProjectBackfiller is the slice of the store the backfill needs: *store.Store satisfies it, and a stub can make either half fail.

Jump to

Keyboard shortcuts

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