Documentation
¶
Overview ¶
Package taskwarrior provides shared helpers for interacting with taskwarrior.
It defines the Task struct with worker UDAs (branch, project_path, 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 ¶
- Variables
- func AddTask(description string, modifiers ...string) (string, error)
- func AnnotateTask(uuid, text string) error
- func Command(args ...string) *exec.Cmd
- func CommandContext(ctx context.Context, args ...string) *exec.Cmd
- func ExtractSessionID(sessionName string) string
- func GetProjects() ([]string, error)
- func GetTags() ([]string, error)
- func IsHexID(s string) bool
- func LoadInlineProjects() []string
- func MarkDeleted(uuid string) error
- func MarkDone(uuid string) error
- func MarkWaiting(uuid string) error
- func ResolveDataLocation() (string, error)
- func SetPRID(uuid, prID string) error
- func SetPRLGTM(uuid string) error
- func SetSpawner(uuid, spawner string) error
- func ShouldInlineNote(note *FlicknoteNote, inlineProjects []string) bool
- func StartTask(uuid string) error
- func UpdateWorkerMetadata(uuid, branch, projectPath string) error
- func ValidateUUID(s string) error
- func VerifyRequiredUDAs() error
- type Annotation
- type FlicknoteNote
- type PRIDInfo
- type Task
- type UserError
Constants ¶
This section is empty.
Variables ¶
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 AnnotateTask ¶ added in v1.0.0
func Command ¶
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 ¶
CommandContext is like Command but with a context for cancellation/timeout.
func ExtractSessionID ¶
ExtractSessionID extracts the UUID[:8] from a session name. Handles both old format (bare UUID[:8]) and new format (w-UUID[:8]-slug).
func GetProjects ¶ added in v1.0.0
func IsHexID ¶
IsHexID returns true if s looks like a bare flicknote/UUID hex prefix (8+ hex chars).
func LoadInlineProjects ¶ added in v1.0.0
func LoadInlineProjects() []string
func MarkDeleted ¶
func MarkWaiting ¶ added in v1.0.0
func ResolveDataLocation ¶
ResolveDataLocation asks taskwarrior for the actual data.location value, respecting the active team's taskrc. Returns the resolved absolute path.
func SetPRLGTM ¶ added in v1.0.0
SetPRLGTM appends :lgtm to the task's pr_id UDA. If already has :lgtm, this is a no-op.
func SetSpawner ¶ added in v1.0.0
SetSpawner sets the spawner UDA on a task (format: team:agent).
func ShouldInlineNote ¶
func ShouldInlineNote(note *FlicknoteNote, inlineProjects []string) bool
func UpdateWorkerMetadata ¶
UpdateWorkerMetadata sets branch and project_path UDAs on a task.
func ValidateUUID ¶
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"`
}
func ReadFlicknoteJSON ¶
func ReadFlicknoteJSON(id string) *FlicknoteNote
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"`
Spawner string `json:"spawner,omitempty"`
}
Task represents a taskwarrior task with worker UDAs.
func ExportTask ¶
func ExportTaskBySessionID ¶
func GetActiveWorkerTasks ¶
func ListTasksWithPR ¶
func (*Task) FormatPrompt ¶
func (*Task) SessionID ¶
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 ¶
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>".