core

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package core defines all the core functionalities to work with tasks.

Index

Constants

View Source
const (
	// TaskIDPrefix is the prefix used for task filenames.
	TaskIDPrefix = "T"
)

Variables

View Source
var ErrInvalid = errors.New("invalid value")

Functions

func RecordChange

func RecordChange(task *Task, change string)

RecordChange adds a history entry to the task for the given change

func SortTasks

func SortTasks(tasks []*Task, sortFields []string, reverse bool)

SortTasks sorts the tasks slice based on the provided sort fields. Supported sort fields: id, title, status, priority, created, updated

Types

type ACManager

type ACManager struct{}

ACManager handles acceptance criteria operations

func NewACManager

func NewACManager() *ACManager

NewACManager creates a new ACManager instance

func (*ACManager) HandleACChanges

func (ac *ACManager) HandleACChanges(task *Task, params EditTaskParams)

HandleACChanges processes acceptance criteria changes for a task

type AcceptanceCriterion

type AcceptanceCriterion struct {
	Text    string `json:"text"`
	Checked bool   `json:"checked"`
	Index   int    `json:"index"`
}

AcceptanceCriterion represents a single item in the acceptance criteria list.

type CreateTaskParams

type CreateTaskParams struct {
	Title        string   `json:"title" jsonschema:"Required. The title of the task."`
	Description  string   `json:"description" jsonschema:"A detailed description of the task."`
	Priority     string   `json:"priority,omitempty" jsonschema:"The priority of the task."`
	Parent       *string  `json:"parent,omitempty" jsonschema:"The ID of the parent task."`
	Assigned     []string `json:"assigned,omitempty" jsonschema:"A list of names assigned."`
	Labels       []string `json:"labels,omitempty" jsonschema:"A list of labels."`
	Dependencies []string `json:"dependencies,omitempty" jsonschema:"A list of task IDs that this task depends on."`
	AC           []string `json:"ac,omitempty" jsonschema:"A list of acceptance criteria."`
	Plan         *string  `json:"plan,omitempty" jsonschema:"The implementation plan."`
	Notes        *string  `json:"notes,omitempty" jsonschema:"Additional notes."`
}

CreateTaskParams holds the parameters for creating a new task.

type EditTaskParams

type EditTaskParams struct {
	ID              string   `json:"id" jsonschema:"Required. The ID of the task to edit."`
	NewTitle        *string  `json:"new_title,omitempty" jsonschema:"A new title for the task."`
	NewDescription  *string  `json:"new_description,omitempty" jsonschema:"A new description for the task."`
	NewStatus       *string  `json:"new_status,omitempty" jsonschema:"A new status (e.g., 'in-progress', 'done')."`
	NewPriority     *string  `json:"new_priority,omitempty" jsonschema:"A new priority."`
	NewParent       *string  `json:"new_parent,omitempty" jsonschema:"A new parent task ID."`
	AddAssigned     []string `json:"add_assigned,omitempty" jsonschema:"A new list of assigned."`
	RemoveAssigned  []string `json:"remove_assigned,omitempty" jsonschema:"A list of assigned to remove."`
	AddLabels       []string `json:"add_labels,omitempty" jsonschema:"Add new list of labels."`
	RemoveLabels    []string `json:"remove_labels,omitempty" jsonschema:"A list of labels to remove."`
	NewDependencies []string `json:"new_dependencies,omitempty" jsonschema:"A new list of dependencies (replaces the old list)."`
	NewNotes        *string  `json:"new_notes,omitempty" jsonschema:"New implementation notes."`
	NewPlan         *string  `json:"new_plan,omitempty" jsonschema:"New implementation plan."`
	AddAC           []string `json:"add_ac,omitempty" jsonschema:"A list of new acceptance criteria to add."`
	CheckAC         []int    `json:"check_ac,omitempty" jsonschema:"A list of 1-based indices of AC to check."`
	UncheckAC       []int    `json:"uncheck_ac,omitempty" jsonschema:"A list of 1-based indices of AC to uncheck."`
	RemoveAC        []int    `json:"remove_ac,omitempty" jsonschema:"A list of 1-based indices of AC to remove."`
}

EditTaskParams holds the parameters for editing a task.

type FileTaskStore

type FileTaskStore struct {
	// contains filtered or unexported fields
}

func NewFileTaskStore

func NewFileTaskStore(fs afero.Fs, tasksDir string) *FileTaskStore

func (*FileTaskStore) Archive

func (f *FileTaskStore) Archive(id TaskID) (string, error)

Archive moves a task to the archived directory and updates its status.

func (*FileTaskStore) Create

func (f *FileTaskStore) Create(params CreateTaskParams) (*Task, error)

Create implements TaskStore.

func (*FileTaskStore) Get

func (f *FileTaskStore) Get(id string) (*Task, error)

Get implements TaskStore.

func (*FileTaskStore) List

func (f *FileTaskStore) List(params ListTasksParams) ([]*Task, error)

List implements TaskStore.

func (*FileTaskStore) Path

func (f *FileTaskStore) Path(t *Task) string

func (*FileTaskStore) Search

func (f *FileTaskStore) Search(query string, listParams ListTasksParams) ([]*Task, error)

Search searches for tasks containing the query string in various fields.

func (*FileTaskStore) Update

func (f *FileTaskStore) Update(task *Task, params EditTaskParams) (*Task, error)

Update updates an existing task based on the provided parameters.

type Frontmatter

type Frontmatter struct {
	ID           string           `yaml:"id"`
	Title        string           `yaml:"title"`
	Status       string           `yaml:"status"`
	Assignee     MaybeStringArray `yaml:"assignee,omitempty"`
	Labels       MaybeStringArray `yaml:"labels,omitempty"`
	Dependencies MaybeStringArray `yaml:"dependencies,omitempty"`
	Parent       string           `yaml:"parent,omitempty"`
	Priority     string           `yaml:"priority,omitempty"`
	CreatedAt    time.Time        `yaml:"created_at"`
	UpdatedAt    time.Time        `yaml:"updated_at,omitempty"`
	History      []HistoryEntry   `yaml:"history,omitempty"`
}

type HistoryEntry

type HistoryEntry struct {
	Timestamp time.Time `yaml:"timestamp" json:"timestamp"`
	Change    string    `yaml:"change" json:"change"`
}

HistoryEntry represents a single entry in the task's history.

type ListTasksParams

type ListTasksParams struct {
	Parent        *string  `json:"parent,omitempty" jsonschema:"Filter tasks by a parent task ID."`
	Status        []string `json:"status,omitempty" jsonschema:"Filter tasks by status."`
	Assigned      []string `json:"assigned,omitempty" jsonschema:"Filter tasks by assignee."`
	Labels        []string `json:"labels,omitempty" jsonschema:"Filter tasks by label."`
	Sort          []string `json:"sort,omitempty" jsonschema:"Fields to sort by."`
	Priority      *string  `json:"priority,omitempty" jsonschema:"Filter tasks by priority."`
	Unassigned    bool     `json:"unassigned,omitempty" jsonschema:"Filter tasks that have no one assigned."`
	DependedOn    bool     `json:"depended_on,omitempty" jsonschema:"Filter tasks that other tasks depend on."`
	HasDependency bool     `json:"has_dependency,omitempty" jsonschema:"Filter tasks that have at least one dependency."`
	Reverse       bool     `json:"reverse,omitempty" jsonschema:"Reverse the sort order."`
}

ListTasksParams holds the parameters for listing tasks.

type MaybeStringArray

type MaybeStringArray []string

MaybeStringArray is a custom type that can unmarshal from either a single string or an array of strings. It also marshals back to the same format, preserving the original structure. origin: https://carlosbecker.com/posts/go-custom-marshaling/

func (MaybeStringArray) MarshalJSON

func (a MaybeStringArray) MarshalJSON() ([]byte, error)

func (MaybeStringArray) MarshalYAML

func (a MaybeStringArray) MarshalYAML() (any, error)

func (*MaybeStringArray) ToSlice added in v0.1.1

func (a *MaybeStringArray) ToSlice() []string

func (*MaybeStringArray) UnmarshalJSON

func (a *MaybeStringArray) UnmarshalJSON(data []byte) error

func (*MaybeStringArray) UnmarshalYAML

func (a *MaybeStringArray) UnmarshalYAML(value *yaml.Node) error

type Priority

type Priority int
const (
	PriorityUnknown Priority = iota
	PriorityLow
	PriorityMedium
	PriorityHigh
	PriorityCritical
)

func ParsePriority

func ParsePriority(s string) (Priority, error)

func (Priority) String

func (p Priority) String() string

type Status

type Status string

Status represents the state of a task.

const (
	StatusTodo       Status = "todo"
	StatusInProgress Status = "in-progress"
	StatusDone       Status = "done"
	StatusCancelled  Status = "cancelled"
	StatusArchived   Status = "archived"
	StatusRejected   Status = "rejected"
)

func ParseStatus

func ParseStatus(s string) (Status, error)

type Task

type Task struct {
	ID           TaskID           `yaml:"id" json:"id"`
	Title        string           `yaml:"title" json:"title"`
	Status       Status           `yaml:"status" json:"status"`
	Parent       TaskID           `yaml:"parent" json:"parent"`
	Assigned     MaybeStringArray `yaml:"assigned,omitempty" json:"assigned,omitempty"`
	Labels       MaybeStringArray `yaml:"labels,omitempty" json:"labels,omitempty"`
	Dependencies MaybeStringArray `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
	Priority     Priority         `yaml:"priority,omitempty" json:"priority,omitempty"`
	CreatedAt    time.Time        `yaml:"created_at" json:"created_at"`
	UpdatedAt    time.Time        `yaml:"updated_at,omitempty" json:"updated_at,omitzero"`
	History      []HistoryEntry   `yaml:"history,omitempty" json:"history,omitempty"`

	Description         string                `json:"description"`
	AcceptanceCriteria  []AcceptanceCriterion `json:"acceptance_criteria"`
	ImplementationPlan  string                `json:"implementation_plan"`
	ImplementationNotes string                `json:"implementation_notes"`
}

Task represents a single task in the backlog. It includes metadata from the front matter and content from the markdown body. The task ID represents a hierarchical structure using dot notation (e.g., "1", "1.1", "1.2", "2"). The task name is derived from the ID and prefixed with "task-" (e.g., "T1", "T1.1").

func FilterTasks

func FilterTasks(tasks []*Task, params ListTasksParams) ([]*Task, error)

FilterTasks applies filtering logic to a slice of tasks

func NewTask

func NewTask() *Task

NewTask creates a new Task with default values.

func (*Task) Bytes

func (t *Task) Bytes() []byte

func (*Task) FileName

func (t *Task) FileName() string

FileName creates a filename from task ID and a slugified title.

type TaskID

type TaskID struct {
	// contains filtered or unexported fields
}

func (TaskID) Equals

func (t TaskID) Equals(other TaskID) bool

func (TaskID) HasSubTasks

func (t TaskID) HasSubTasks() bool

HasSubTasks returns true if the task ID has subtask segments (i.e., more than one segment).

func (TaskID) Less

func (t TaskID) Less(other TaskID) bool

func (TaskID) MarshalJSON

func (t TaskID) MarshalJSON() ([]byte, error)

func (TaskID) MarshalText

func (t TaskID) MarshalText() ([]byte, error)

func (TaskID) MarshalYAML

func (t TaskID) MarshalYAML() (any, error)

func (TaskID) Name

func (t TaskID) Name() string

Name returns the filename prefix for the task, e.g., "T1.02.03".

func (TaskID) NextSiblingID

func (t TaskID) NextSiblingID() TaskID

func (TaskID) NextSubTaskID

func (t TaskID) NextSubTaskID() TaskID

func (TaskID) Parent

func (t TaskID) Parent() *TaskID

func (TaskID) String

func (t TaskID) String() string

String returns the string representation of the TaskID (e.g., "1.02.03").

func (*TaskID) UnmarshalJSON

func (t *TaskID) UnmarshalJSON(data []byte) error

func (*TaskID) UnmarshalText

func (t *TaskID) UnmarshalText(text []byte) error

func (*TaskID) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

Jump to

Keyboard shortcuts

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