task

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PriorityHigh       = 1
	PriorityMediumHigh = 2
	PriorityMedium     = 3
	PriorityMediumLow  = 4
	PriorityLow        = 5
)

Priority scale: lower = higher priority 1 = highest, 5 = lowest

View Source
const (
	StatusBacklog    = workflow.StatusBacklog
	StatusReady      = workflow.StatusReady
	StatusInProgress = workflow.StatusInProgress
	StatusReview     = workflow.StatusReview
	StatusDone       = workflow.StatusDone
)

convenience constants matching the default workflow.yaml statuses.

View Source
const (
	TypeStory = workflow.TypeStory
	TypeBug   = workflow.TypeBug
	TypeSpike = workflow.TypeSpike
	TypeEpic  = workflow.TypeEpic
)

well-known built-in type constants.

View Source
const (
	MinPriority     = 1
	MaxPriority     = 5
	DefaultPriority = 3 // Medium
)

Priority validation constants

View Source
const DateFormat = "2006-01-02"

Variables

This section is empty.

Functions

func AllFrequencies added in v0.3.1

func AllFrequencies() []string

AllFrequencies returns the ordered list of frequencies for the UI.

func AllPriorityDisplayValues added in v0.3.1

func AllPriorityDisplayValues() []string

AllPriorityDisplayValues returns priority display labels ordered high→low (1→5).

func AllRecurrenceDisplayValues added in v0.3.1

func AllRecurrenceDisplayValues() []string

AllRecurrenceDisplayValues returns the ordered list of display values for UI selection.

func AllValidators added in v0.4.0

func AllValidators() []func(*Task) string

AllValidators returns the complete list of field validation functions. Each returns an error message (empty string = valid).

func AllWeekdays added in v0.3.1

func AllWeekdays() []string

AllWeekdays returns weekday names in order for the UI.

func DayOfMonthFromRecurrence added in v0.3.1

func DayOfMonthFromRecurrence(r Recurrence) (int, bool)

DayOfMonthFromRecurrence extracts the day (1-31) from a monthly cron expression.

func IsActiveStatus added in v0.1.5

func IsActiveStatus(status Status) bool

IsActiveStatus reports whether the status has the active flag set.

func IsMonthlyRecurrence added in v0.3.1

func IsMonthlyRecurrence(r Recurrence) (int, bool)

IsMonthlyRecurrence checks if a recurrence is a monthly pattern. Returns the day of month and true if it matches "0 0 N * *".

func IsValidPoints added in v0.0.4

func IsValidPoints(points int) bool

IsValidPoints checks if a points value is within the valid range.

func IsValidPriority added in v0.0.4

func IsValidPriority(priority int) bool

IsValidPriority checks if a priority value is within the valid range.

func IsValidRecurrence added in v0.3.1

func IsValidRecurrence(r Recurrence) bool

IsValidRecurrence returns true if the recurrence is empty or matches a known or monthly pattern.

func IsValidTikiIDFormat added in v0.4.0

func IsValidTikiIDFormat(id string) bool

IsValidTikiIDFormat checks if a string matches the TIKI-XXXXXX format where X is an uppercase alphanumeric character.

func MonthlyDisplay added in v0.3.1

func MonthlyDisplay(day int) string

MonthlyDisplay returns a human-readable string like "Monthly on the 15th".

func NextOccurrence added in v0.3.1

func NextOccurrence(r Recurrence) time.Time

NextOccurrence computes the next occurrence date from today for a given recurrence. Returns zero time for RecurrenceNone.

func NextOccurrenceFrom added in v0.3.1

func NextOccurrenceFrom(r Recurrence, ref time.Time) time.Time

NextOccurrenceFrom computes the next occurrence date relative to ref. Only the date part of ref is used; result is always midnight UTC. Only daily, weekly, and monthly recurrences are supported. Unrecognized patterns return zero time, same as RecurrenceNone.

func NormalizePriority

func NormalizePriority(priority string) int

NormalizePriority standardizes a raw priority string or number into an integer. Returns the normalized priority value (clamped to 1-5) or -1 if invalid.

func OrdinalSuffix added in v0.3.1

func OrdinalSuffix(n int) string

OrdinalSuffix returns the ordinal suffix for a number (st, nd, rd, th).

func ParseDueDate added in v0.3.1

func ParseDueDate(s string) (time.Time, bool)

ParseDueDate parses a date string in YYYY-MM-DD format. Returns (time.Time, true) on success, (zero time, false) on failure. Empty string is treated as valid and returns zero time with true.

func PriorityDisplay added in v0.3.1

func PriorityDisplay(priority int) string

PriorityDisplay returns the human-readable label for a priority integer. e.g., 1 → "High", 3 → "Medium", 5 → "Low"

func PriorityFromDisplay added in v0.3.1

func PriorityFromDisplay(display string) int

PriorityFromDisplay converts a display label back to a priority integer. e.g., "High" → 1, "Medium Low" → 4. Returns PriorityMedium if not found.

func PriorityLabel

func PriorityLabel(priority int) string

PriorityLabel returns an emoji-based label for a priority value.

func RecurrenceDisplay added in v0.3.1

func RecurrenceDisplay(r Recurrence) string

RecurrenceDisplay converts a cron expression to English display.

func StatusDisplay

func StatusDisplay(status Status) string

StatusDisplay returns "Label Emoji" for a status.

func StatusEmoji

func StatusEmoji(status Status) string

StatusEmoji returns the emoji for a status from the registry.

func StatusLabel

func StatusLabel(status Status) string

StatusLabel returns the display label for a status from the registry.

func StatusToString

func StatusToString(status Status) string

StatusToString converts a Status to its string representation.

func TypeDisplay

func TypeDisplay(taskType Type) string

TypeDisplay returns a formatted display string with label and emoji.

func TypeEmoji

func TypeEmoji(taskType Type) string

TypeEmoji returns the emoji for a task type.

func TypeLabel

func TypeLabel(taskType Type) string

TypeLabel returns a human-readable label for a task type.

func ValidateDependsOn added in v0.4.0

func ValidateDependsOn(t *Task) string

ValidateDependsOn returns an error message if any dependency ID is malformed.

func ValidateDue added in v0.4.0

func ValidateDue(t *Task) string

ValidateDue returns an error message if the due date is not normalized to midnight UTC.

func ValidatePoints added in v0.4.0

func ValidatePoints(t *Task) string

ValidatePoints returns an error message if story points are out of range.

func ValidatePriority added in v0.4.0

func ValidatePriority(t *Task) string

ValidatePriority returns an error message if the task priority is out of range.

func ValidateRecurrence added in v0.4.0

func ValidateRecurrence(t *Task) string

ValidateRecurrence returns an error message if the recurrence pattern is invalid.

func ValidateStatus added in v0.4.0

func ValidateStatus(t *Task) string

ValidateStatus returns an error message if the task status is invalid.

func ValidateTitle added in v0.4.0

func ValidateTitle(t *Task) string

ValidateTitle returns an error message if the task title is invalid.

func ValidateType added in v0.4.0

func ValidateType(t *Task) string

ValidateType returns an error message if the task type is invalid.

func WeekdayFromRecurrence added in v0.3.1

func WeekdayFromRecurrence(r Recurrence) (string, bool)

WeekdayFromRecurrence extracts the weekday name from a weekly cron expression.

Types

type Comment

type Comment struct {
	ID        string
	Author    string
	Text      string
	CreatedAt time.Time
}

Comment represents a comment on a task

type DependsOnValue added in v0.3.0

type DependsOnValue []string

DependsOnValue is a custom type for dependsOn that provides lenient YAML unmarshaling. It gracefully handles invalid YAML by defaulting to an empty slice instead of failing. Values are uppercased to ensure consistent TIKI-XXXXXX format.

func (DependsOnValue) MarshalYAML added in v0.3.0

func (d DependsOnValue) MarshalYAML() (any, error)

MarshalYAML implements YAML marshaling for DependsOnValue. Returns the underlying slice as-is for standard YAML serialization.

func (DependsOnValue) ToStringSlice added in v0.3.0

func (d DependsOnValue) ToStringSlice() []string

ToStringSlice converts DependsOnValue to []string for use with Task entity.

func (*DependsOnValue) UnmarshalYAML added in v0.3.0

func (d *DependsOnValue) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for dependsOn with lenient error handling. Valid YAML list formats are parsed normally. Invalid formats (scalars, objects, etc.) default to empty slice with a warning log instead of returning an error.

type DueValue added in v0.3.1

type DueValue struct {
	time.Time
}

DueValue is a custom type for due dates that provides lenient YAML unmarshaling. It gracefully handles invalid YAML by defaulting to zero time instead of failing. Embeds time.Time to inherit IsZero() method (required for yaml:",omitempty").

func (DueValue) MarshalYAML added in v0.3.1

func (d DueValue) MarshalYAML() (any, error)

MarshalYAML implements YAML marshaling for DueValue. Returns empty string for zero time, otherwise formats as YYYY-MM-DD.

func (DueValue) ToTime added in v0.3.1

func (d DueValue) ToTime() time.Time

ToTime converts DueValue to time.Time for use with Task entity.

func (*DueValue) UnmarshalYAML added in v0.3.1

func (d *DueValue) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for due dates with lenient error handling. Valid date strings in YYYY-MM-DD format are parsed normally. Invalid formats or types default to zero time with a warning log instead of returning an error.

type PriorityValue

type PriorityValue int

PriorityValue unmarshals priority from int or string (e.g., "high", "medium-high"). high=1, low=5. Values outside 1-5 range are clamped to boundaries.

func (PriorityValue) MarshalYAML

func (p PriorityValue) MarshalYAML() (interface{}, error)

func (*PriorityValue) UnmarshalYAML

func (p *PriorityValue) UnmarshalYAML(value *yaml.Node) error

type Recurrence added in v0.3.1

type Recurrence string

Recurrence represents a task recurrence pattern as a cron expression. Empty string means no recurrence.

const (
	RecurrenceNone    Recurrence = ""
	RecurrenceDaily   Recurrence = "0 0 * * *"
	RecurrenceMonthly Recurrence = "0 0 1 * *"
)

func MonthlyRecurrence added in v0.3.1

func MonthlyRecurrence(day int) Recurrence

MonthlyRecurrence creates a monthly cron expression for the given day (1-31).

func ParseRecurrence added in v0.3.1

func ParseRecurrence(s string) (Recurrence, bool)

ParseRecurrence validates a cron string against known patterns or monthly pattern.

func RecurrenceFromDisplay added in v0.3.1

func RecurrenceFromDisplay(display string) Recurrence

RecurrenceFromDisplay converts an English display string to a cron expression.

func WeeklyRecurrence added in v0.3.1

func WeeklyRecurrence(dayName string) Recurrence

WeeklyRecurrence creates a weekly cron expression for the given day name.

type RecurrenceFrequency added in v0.3.1

type RecurrenceFrequency string

RecurrenceFrequency represents a high-level recurrence category for the UI editor.

const (
	FrequencyNone    RecurrenceFrequency = "None"
	FrequencyDaily   RecurrenceFrequency = "Daily"
	FrequencyWeekly  RecurrenceFrequency = "Weekly"
	FrequencyMonthly RecurrenceFrequency = "Monthly"
)

func FrequencyFromRecurrence added in v0.3.1

func FrequencyFromRecurrence(r Recurrence) RecurrenceFrequency

FrequencyFromRecurrence extracts the high-level frequency from a cron expression.

type RecurrenceValue added in v0.3.1

type RecurrenceValue struct {
	Value Recurrence
}

RecurrenceValue is a custom type for recurrence that provides lenient YAML unmarshaling.

func (RecurrenceValue) IsZero added in v0.3.1

func (r RecurrenceValue) IsZero() bool

IsZero reports whether the recurrence is empty (needed for omitempty).

func (RecurrenceValue) MarshalYAML added in v0.3.1

func (r RecurrenceValue) MarshalYAML() (any, error)

MarshalYAML implements YAML marshaling for RecurrenceValue.

func (RecurrenceValue) ToRecurrence added in v0.3.1

func (r RecurrenceValue) ToRecurrence() Recurrence

ToRecurrence converts RecurrenceValue to Recurrence.

func (*RecurrenceValue) UnmarshalYAML added in v0.3.1

func (r *RecurrenceValue) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for recurrence with lenient error handling.

type SearchResult

type SearchResult struct {
	Task  *Task
	Score float64 // relevance score (higher = better match)
}

SearchResult represents a task match with relevance score

type Status

type Status = workflow.StatusKey

Status is a type alias for workflow.StatusKey. This preserves compatibility: task.Status and workflow.StatusKey are the same type.

func AllStatuses added in v0.1.5

func AllStatuses() []Status

AllStatuses returns the ordered list of all configured statuses.

func DefaultStatus added in v0.1.5

func DefaultStatus() Status

DefaultStatus returns the status configured as default in workflow.yaml.

func DoneStatus added in v0.1.5

func DoneStatus() Status

DoneStatus returns the status configured as done in workflow.yaml.

func MapStatus

func MapStatus(status string) Status

MapStatus maps a raw status string to a Status constant.

func NormalizeStatus

func NormalizeStatus(status string) Status

NormalizeStatus standardizes a raw status string into a Status.

func ParseStatus added in v0.0.4

func ParseStatus(status string) (Status, bool)

ParseStatus normalizes a raw status string and validates it against the registry. Empty input returns the configured default status. Unknown values return (DefaultStatus(), false).

type TagsValue

type TagsValue []string

TagsValue is a custom type for tags that provides lenient YAML unmarshaling. It gracefully handles invalid YAML by defaulting to an empty slice instead of failing.

func (TagsValue) MarshalYAML

func (t TagsValue) MarshalYAML() (interface{}, error)

MarshalYAML implements YAML marshaling for TagsValue. Returns the underlying slice as-is for standard YAML serialization.

func (TagsValue) ToStringSlice

func (t TagsValue) ToStringSlice() []string

ToStringSlice converts TagsValue to []string for use with Task entity.

func (*TagsValue) UnmarshalYAML

func (t *TagsValue) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling for tags with lenient error handling. Valid YAML list formats are parsed normally. Invalid formats (scalars, objects, etc.) default to empty slice with a warning log instead of returning an error.

type Task

type Task struct {
	ID          string
	Title       string
	Description string
	Type        Type
	Status      Status
	Tags        []string
	DependsOn   []string
	Due         time.Time
	Recurrence  Recurrence
	Assignee    string
	Priority    int // lower = higher priority
	Points      int
	Comments    []Comment
	CreatedBy   string // User who initially created the task
	CreatedAt   time.Time
	UpdatedAt   time.Time
	LoadedMtime time.Time // File mtime when loaded (for optimistic locking)
}

Task represents a work item (user story, bug, etc.)

func FindBlockedTasks added in v0.3.1

func FindBlockedTasks(allTasks []*Task, taskID string) []*Task

FindBlockedTasks returns all tasks whose DependsOn list contains the given task ID. These are the downstream tasks that are waiting on taskID to be completed.

func (*Task) Clone

func (t *Task) Clone() *Task

Clone creates a deep copy of the task

type Type

type Type = workflow.TaskType

Type is a type alias for workflow.TaskType. This preserves compatibility: task.Type and workflow.TaskType are the same type.

func AllTypes added in v0.4.0

func AllTypes() []Type

AllTypes returns the ordered list of all configured type keys.

func NormalizeType

func NormalizeType(t string) Type

NormalizeType standardizes a raw type string into a Type.

func ParseDisplay added in v0.4.0

func ParseDisplay(display string) (Type, bool)

ParseDisplay reverses a TypeDisplay() string back to a canonical key. Returns (key, true) on match, or (fallback, false) for unrecognized display strings.

func ParseType added in v0.0.4

func ParseType(t string) (Type, bool)

ParseType parses a raw string into a Type with validation. Returns the canonical key and true if recognized (including aliases), or (TypeStory, false) for unknown types.

Jump to

Keyboard shortcuts

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