taskwarrior

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

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 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 ExtractSessionID

func ExtractSessionID(sessionName string) string

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

func IsHexID

func IsHexID(s string) bool

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

func MarkDeleted

func MarkDeleted(uuid string) error

MarkDeleted marks a task as deleted (for failed workers).

func MarkDone

func MarkDone(uuid string) error

MarkDone marks a task as completed.

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 ShouldInlineNote

func ShouldInlineNote(note *FlicknoteNote) bool

ShouldInlineNote returns true if the note's project indicates it's a plan/design doc. Matches both "plan" and "design" for consistency with inlineRefPattern (Plan:/Design:).

func StartTask

func StartTask(uuid string) error

StartTask marks a task as started so it appears in +ACTIVE.

func UpdateWorkerMetadata

func UpdateWorkerMetadata(uuid, branch, projectPath string) error

UpdateWorkerMetadata sets branch and project_path UDAs on a 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 branch and project_path 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"`
}

FlicknoteNote represents the JSON output of `flicknote get --json`.

func ReadFlicknoteJSON

func ReadFlicknoteJSON(id string) *FlicknoteNote

ReadFlicknoteJSON fetches a note's metadata from flicknote CLI. Returns nil if flicknote is not installed, ID not found, or JSON parse fails.

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"`
	Branch      string       `json:"branch"`
	ProjectPath string       `json:"project_path"`
	PRID        string       `json:"pr_id,omitempty"`
}

Task represents a taskwarrior task with worker UDAs.

func ExportTask

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

ExportTask loads a task by UUID from taskwarrior.

func ExportTaskBySessionID

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

ExportTaskBySessionID finds a task by UUID prefix (first 8 chars). If status is non-empty, filters by that status.

func FindTasks

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

FindTasks searches for tasks matching any of the given keywords (OR logic). status filters by task status (e.g. "pending", "completed"). Empty means no filter.

func GetActiveWorkerTasks

func GetActiveWorkerTasks() ([]Task, error)

GetActiveWorkerTasks returns all pending+active tasks that have a branch UDA (worker tasks).

func ListTasksWithPR

func ListTasksWithPR() ([]Task, error)

ListTasksWithPR exports active tasks that have a pr_id UDA set.

func (*Task) FormatPrompt

func (t *Task) FormatPrompt() string

FormatPrompt formats the task for injection into a worker's Claude prompt. Includes description, annotations, and selectively inlined referenced docs. File refs use prefix-based logic (Plan:/Design: → inline, Research:/Doc: → don't). Hex IDs (bare or prefixed like "Plan: abc123") use project-based logic via flicknote: inline if the note's project contains "plan" or "design".

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 derived from branch (preferred) or task description (fallback).

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