taskwarrior

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package taskwarrior provides shared helpers for interacting with taskwarrior.

It defines the Task struct with worker UDAs (branch, pr_id, spawner), UUID validation and slug generation for session naming, task export and query helpers, flicknote annotation resolution, and UDA verification. Used by CLI commands, the daemon, and worker hooks throughout both planes.

Plane: shared

Index

Constants

This section is empty.

Variables

View Source
var HexIDPattern = regexp.MustCompile(`\b([a-f0-9]{8,})\b`)

HexIDPattern finds a flicknote hex ID (8+ lowercase hex chars) anywhere in an annotation. Matches bare IDs ("e8fd0fe0"), prefixed ("Plan: e8fd0fe0"), or multi-word ("Plan: flicknote b7b61e89"). If the ID doesn't exist in flicknote, ReadFlicknoteJSON returns nil and the annotation is suppressed from the prompt.

Functions

func AddTask added in v1.0.0

func AddTask(description string, modifiers ...string) (string, error)

func AnnotateTask added in v1.0.0

func AnnotateTask(uuid, text string) error

func Command

func Command(args ...string) *exec.Cmd

Command builds an exec.Cmd for `task` with the active team's TASKRC prepended as `rc:<path>`. This ensures all task invocations target the correct taskwarrior instance regardless of the calling process's env.

Usage:

cmd := taskwarrior.Command("status:pending", "export")
out, err := cmd.Output()

func CommandContext

func CommandContext(ctx context.Context, args ...string) *exec.Cmd

CommandContext is like Command but with a context for cancellation/timeout.

func CountTasks added in v1.7.0

func CountTasks(filters ...string) (int, error)

CountTasks returns the count of tasks matching the given filters.

func ExtractSessionID

func ExtractSessionID(sessionName string) string

ExtractSessionID extracts the UUID[:8] from a session name. Handles w-UUID[:8]-slug (worker) and bare UUID[:8].

func GetProjects added in v1.0.0

func GetProjects() ([]string, error)

func GetTags added in v1.0.0

func GetTags() ([]string, error)

func HasAnyLGTMTag added in v1.8.0

func HasAnyLGTMTag(tags []string) bool

HasAnyLGTMTag returns true if any tag in the slice is a stage lgtm tag.

func HasTag added in v1.7.0

func HasTag(tags []string, tag string) bool

HasTag returns true if tags contains the given tag.

func IsHexID

func IsHexID(s string) bool

IsHexID returns true if s looks like a bare flicknote/UUID hex prefix (8+ hex chars).

func IsLGTMTag added in v1.8.0

func IsLGTMTag(tag string) bool

IsLGTMTag reports whether tag is a stage-specific lgtm tag (ends with "_lgtm").

func LoadInlineProjects added in v1.0.0

func LoadInlineProjects() []string

func MarkDeleted

func MarkDeleted(uuid string) error

func MarkDone

func MarkDone(uuid string) error

func MarkWaiting added in v1.0.0

func MarkWaiting(uuid string) error

func ModifyTags added in v1.7.0

func ModifyTags(uuid string, tags ...string) error

ModifyTags adds or removes tags from a task. Tags should be in "+tagname" or "-tagname" format.

func ResolveDataLocation

func ResolveDataLocation() (string, error)

ResolveDataLocation asks taskwarrior for the actual data.location value, respecting the active team's taskrc. Returns the resolved absolute path.

func SetPRID

func SetPRID(uuid, prID string) error

SetPRID sets the pr_id UDA on a task.

func SetSpawner added in v1.0.0

func SetSpawner(uuid, spawner string) error

SetSpawner sets the spawner UDA on a task (format: team:agent).

func ShouldInlineNote

func ShouldInlineNote(note *FlicknoteNote, inlineProjects []string) bool

func StartTask

func StartTask(uuid string) error

func StopTask added in v1.7.0

func StopTask(uuid string) error

StopTask stops an active task.

func ValidateUUID

func ValidateUUID(s string) error

ValidateUUID checks that s is a valid taskwarrior UUID. Returns a user-friendly error for numeric IDs, # prefixes, or invalid formats.

func VerifyRequiredUDAs

func VerifyRequiredUDAs() error

VerifyRequiredUDAs checks that required UDAs are configured in taskwarrior.

Types

type Annotation

type Annotation struct {
	Description string `json:"description"`
	Entry       string `json:"entry,omitempty"`
}

Annotation represents a taskwarrior annotation.

type FlicknoteNote

type FlicknoteNote struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Project string `json:"project"`
	Summary string `json:"summary"`
	Content string `json:"content"`
}

func ReadFlicknoteJSON

func ReadFlicknoteJSON(id string) *FlicknoteNote

type PRIDInfo added in v1.0.0

type PRIDInfo struct {
	Index int64
}

PRIDInfo holds parsed pr_id UDA data.

func ParsePRID added in v1.0.0

func ParsePRID(raw string) (PRIDInfo, error)

ParsePRID parses a pr_id UDA value. Strips legacy ":lgtm" suffix for backward compat.

type Task

type Task struct {
	ID          int          `json:"id"`
	UUID        string       `json:"uuid"`
	Description string       `json:"description"`
	Project     string       `json:"project,omitempty"`
	Status      string       `json:"status"`
	Tags        []string     `json:"tags,omitempty"`
	Annotations []Annotation `json:"annotations,omitempty"`
	Start       string       `json:"start,omitempty"`
	Modified    string       `json:"modified,omitempty"`
	Scheduled   string       `json:"scheduled,omitempty"`
	PRID        string       `json:"pr_id,omitempty"`
	Spawner     string       `json:"spawner,omitempty"`
}

Task represents a taskwarrior task with worker UDAs.

func ExportTask

func ExportTask(uuid string) (*Task, error)

func ExportTaskBySessionID

func ExportTaskBySessionID(sessionID, status string) (*Task, error)

func ExportTasksByFilter added in v1.7.0

func ExportTasksByFilter(args ...string) ([]Task, error)

ExportTasksByFilter runs a task export with the given filter args.

func FindTasks

func FindTasks(keywords []string, status string) ([]Task, error)

func GetActiveWorkerTasks

func GetActiveWorkerTasks() ([]Task, error)

func GetDueReminders added in v1.2.0

func GetDueReminders() ([]Task, error)

GetDueReminders returns pending tasks tagged +reminder with scheduled <= now. Used by the daemon poller to fire notifications.

func GetPendingReminders added in v1.2.0

func GetPendingReminders() ([]Task, error)

GetPendingReminders returns all pending tasks tagged +reminder (for `ttal remind list`).

func ListTasksWithPR

func ListTasksWithPR() ([]Task, error)

func (*Task) FormatPrompt

func (t *Task) FormatPrompt() string

func (*Task) HasTag

func (t *Task) HasTag(tag string) bool

HasTag returns true if the task has the given tag.

func (*Task) SessionID

func (t *Task) SessionID() string

SessionID returns a deterministic session identifier derived from the task UUID. Uses the first 8 characters of the UUID (4 billion possible values).

func (*Task) SessionName

func (t *Task) SessionName() string

SessionName returns a human-readable session name: w-{uuid[:8]}-{slug}. Slug is always derived from the task description, which is immutable and stable across the task lifetime. This ensures open/attach commands always find the session regardless of when they run relative to UDA writes.

Worker sessions use this format to be identifiable at a glance:

w-e9d4b7c1-fix-auth
w-a3f29bc0-add-doctor

This is distinct from agent sessions which use "ttal-<team>-<agent>".

type UserError

type UserError struct {
	Msg string
}

UserError is an error with a user-facing message intended for CLI display. The message may contain newlines and formatting.

func (*UserError) Error

func (e *UserError) Error() string

Jump to

Keyboard shortcuts

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