Documentation
¶
Overview ¶
Package core defines all the core functionalities to work with tasks.
Index ¶
- Constants
- Variables
- func RecordChange(task *Task, change string)
- func SortTasks(tasks []*Task, sortFields []string, reverse bool)
- type ACManager
- type AcceptanceCriterion
- type CreateTaskParams
- type EditTaskParams
- type FileTaskStore
- func (f *FileTaskStore) Archive(id TaskID) (string, error)
- func (f *FileTaskStore) Create(params CreateTaskParams) (*Task, error)
- func (f *FileTaskStore) Get(id string) (*Task, error)
- func (f *FileTaskStore) List(params ListTasksParams) ([]*Task, error)
- func (f *FileTaskStore) Path(t *Task) string
- func (f *FileTaskStore) Search(query string, listParams ListTasksParams) ([]*Task, error)
- func (f *FileTaskStore) Update(task *Task, params EditTaskParams) (*Task, error)
- type Frontmatter
- type HistoryEntry
- type ListResult
- type ListTasksParams
- type MaybeStringArray
- type PaginationInfo
- type Priority
- type Status
- type Task
- type TaskID
- func (t TaskID) Equals(other TaskID) bool
- func (t TaskID) HasSubTasks() bool
- func (t TaskID) Less(other TaskID) bool
- func (t TaskID) MarshalJSON() ([]byte, error)
- func (t TaskID) MarshalText() ([]byte, error)
- func (t TaskID) MarshalYAML() (any, error)
- func (t TaskID) Name() string
- func (t TaskID) NextSiblingID() TaskID
- func (t TaskID) NextSubTaskID() TaskID
- func (t TaskID) Parent() *TaskID
- func (t TaskID) String() string
- func (t *TaskID) UnmarshalJSON(data []byte) error
- func (t *TaskID) UnmarshalText(text []byte) error
- func (t *TaskID) UnmarshalYAML(value *yaml.Node) error
Constants ¶
const (
// TaskIDPrefix is the prefix used for task filenames.
TaskIDPrefix = "T"
)
Variables ¶
var ErrInvalid = errors.New("invalid value")
var ZeroTaskID = TaskID{/* contains filtered or unexported fields */}
Functions ¶
func RecordChange ¶
RecordChange adds a history entry to the task for the given change
Types ¶
type ACManager ¶
type ACManager struct{}
ACManager handles acceptance criteria operations
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 ListResult ¶ added in v0.3.0
type ListResult struct {
Tasks []*Task `json:"tasks"`
Pagination *PaginationInfo `json:"pagination,omitempty"`
}
ListResult contains the tasks and pagination metadata
type ListTasksParams ¶
type ListTasksParams struct {
// TODO: rangeID
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."`
// Pagination
Limit *int `json:"limit,omitempty" jsonschema:"Maximum number of tasks to return (0 means no limit)."`
Offset *int `json:"offset,omitempty" jsonschema:"Number of tasks to skip from the beginning."`
}
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 PaginationInfo ¶ added in v0.3.0
type PaginationInfo struct {
TotalResults int `json:"total_results"`
DisplayedResults int `json:"displayed_results"`
Offset int `json:"offset"`
Limit int `json:"limit"`
HasMore bool `json:"has_more"`
}
PaginationInfo contains metadata about pagination results
type Priority ¶
type Priority int
func ParsePriority ¶
func (Priority) MarshalJSON ¶ added in v0.2.5
func (Priority) MarshalYAML ¶ added in v0.2.5
func (*Priority) UnmarshalJSON ¶ added in v0.2.5
UnmarshalJSON implements json.Unmarshaler.
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 PaginateTasks ¶ added in v0.3.0
PaginateTasks applies pagination to a slice of tasks. If limit is nil or 0, returns all tasks. If offset is nil, defaults to 0.
type TaskID ¶
type TaskID struct {
// contains filtered or unexported fields
}
func (TaskID) HasSubTasks ¶
HasSubTasks returns true if the task ID has subtask segments (i.e., more than one segment).