Documentation
¶
Index ¶
- Variables
- func AddInterval(t time.Time, interval int, unit byte) time.Time
- func ClipDuration(entry ClockEntry, rangeStart, rangeEnd time.Time) time.Duration
- func ClockIn(t *Task) error
- func ClockOut(t *Task) error
- func CompleteRecurringTask(t *Task, c *config.Config, targetKeyword string) (advanced bool, err error)
- func DetectCycles(tasks []*Task)
- func FindFiles(c *config.Config, project string) ([]string, error)
- func FormatDuration(d time.Duration) string
- func GetAllKeywords(c *config.Config) map[string][]string
- func GetZettelTitle(zetDir, zetID string) (string, error)
- func HasActiveChildren(t *Task, c *config.Config) bool
- func IsClockActive(t *Task) bool
- func IsCompletedKeyword(c *config.Config, keyword string) bool
- func IsJiraID(id string) bool
- func IsKeywordValid(c *config.Config, keyword string) bool
- func IsValidZettelID(id string) bool
- func ReadRawBlock(t *Task) (string, error)
- func RecordCompletion(t *Task) error
- func RecordStateTransition(t *Task, fromKeyword, toKeyword string) error
- func RenderMarkdownDescription(description string, taskColor lipgloss.Style) string
- func SetTaskDate(t *Task, scheduledAt, dueAt string, removeScheduled, removeDue bool) error
- func SortByPriority(tasks []*Task, c *config.Config)
- func StripLinePrefix(line string) (string, int)
- func SummarizeProjects(c *config.Config) (map[string]int, error)
- func SyncFromJira(ctx context.Context, cfg *config.Config, client *jira.Client) (int, error)
- func TruncateString(s string, maxWidth int) string
- func UpdateTaskLabels(t *Task, labels []string) error
- func UpdateTaskStatus(t *Task, newKeyword string, cfg *config.Config) error
- type AgendaDay
- type AgendaItem
- type ClockEntry
- type ClockInArgs
- type ClockOutArgs
- type ClockProjectResult
- type ClockResult
- type ClockTable
- type ClockTableEntry
- type ClockTableProject
- type ClockTableResult
- type ClockTaskResult
- type CompletionEntry
- type CountTasksArgs
- type CountTasksResult
- type DatePicker
- type DatePickerField
- type FilterTasksArgs
- type FilterTasksResult
- type GetClockTableArgs
- type GetCycleTasksArgs
- type GetCycleTasksResult
- type GetDependenciesArgs
- type GetDependenciesResult
- type GetDependentsArgs
- type GetDependentsResult
- type GetKeywordsArgs
- type GetKeywordsResult
- type GetProjectsArgs
- type GetProjectsResult
- type GetTaskArgs
- type GetTaskByIDArgs
- type GetTaskByIDResult
- type GetTaskResult
- type KeywordEntry
- type ListTasksArgs
- type ListTasksResult
- type MCPServer
- type ProjectInfo
- type RecurrenceMode
- type RecurrenceSpec
- type Schedule
- type ScheduleTaskArgs
- type ScheduleTaskResult
- type SearchResult
- type SearchResultInfo
- type SearchTasksArgs
- type SearchTasksResult
- type StateTransition
- type StatusPicker
- type SyncJiraArgs
- type SyncJiraResult
- type Task
- func FilterTasks(tasks []*Task, filterString string) []*Task
- func FindActiveClocks(tasks []*Task) []*Task
- func GetDependencies(tasks []*Task, t *Task) []*Task
- func GetDependents(tasks []*Task, t *Task) []*Task
- func GetTaskByID(tasks []*Task, id string) *Task
- func GroupWithChildren(tasks []*Task) []*Task
- func ListTasks(c *config.Config, project string, showCompleted bool) ([]*Task, error)
- func ParseLine(c *config.Config, line, project, zettel, filePath string) *Task
- func ProcessFile(c *config.Config, filePath string) ([]*Task, error)
- func (t *Task) IsActive(c *config.Config) bool
- func (t *Task) IsCompleted(c *config.Config) bool
- func (t *Task) IsInProgress(c *config.Config) bool
- func (t *Task) IsSomeday(c *config.Config) bool
- func (t *Task) PendingChildCount(c *config.Config) (done, total int)
- func (t *Task) Priority(c *config.Config) int
- type TaskInfo
- type UpdateTaskStatusArgs
- type UpdateTaskStatusResult
- type WarningSpec
Constants ¶
This section is empty.
Variables ¶
var ErrPendingChildren = errors.New("cannot complete: active child tasks pending")
ErrPendingChildren is returned by UpdateTaskStatus when a task can't be marked completed because it still has active or in-progress children.
Functions ¶
func AddInterval ¶
AddInterval adds N units to the given time, handling month overflow.
func ClipDuration ¶
func ClipDuration(entry ClockEntry, rangeStart, rangeEnd time.Time) time.Duration
ClipDuration returns the duration of a clock entry clipped to [rangeStart, rangeEnd]. Open entries use time.Now() as end. Returns 0 if entry doesn't overlap the range.
func ClockIn ¶
ClockIn appends a new open CLOCK entry after the task line. Returns error if task already has an active clock.
func ClockOut ¶
ClockOut completes the open CLOCK entry for the task. Returns error if no active clock found.
func CompleteRecurringTask ¶
func CompleteRecurringTask(t *Task, c *config.Config, targetKeyword string) (advanced bool, err error)
CompleteRecurringTask handles advancing a recurring task's date on completion. Returns advanced=true if the task was recurring and the date was advanced. If not recurring, returns false and the caller should proceed with normal completion. Auto-clocks-out if the task has an active clock, then records a LOG transition entry.
func DetectCycles ¶
func DetectCycles(tasks []*Task)
DetectCycles finds all tasks that participate in circular dependencies. It builds a directed graph from task references and uses DFS to detect cycles. Tasks participating in cycles will have their InCycle field set to true.
func FindFiles ¶
FindFiles finds README.md files in project directories (structured mode) or all .md files in the project tree (unstructured mode)
func FormatDuration ¶
FormatDuration formats a duration as H:MM.
func GetAllKeywords ¶
GetAllKeywords returns all configured keywords grouped by category
func GetZettelTitle ¶
GetZettelTitle gets the title of a zettel from its README.md file
func HasActiveChildren ¶
HasActiveChildren returns true if any direct child of t is active or in-progress.
func IsClockActive ¶
IsClockActive returns true if the task has an open (running) clock entry.
func IsCompletedKeyword ¶
IsCompletedKeyword checks whether the given keyword is in the configured Completed list.
func IsKeywordValid ¶
IsKeywordValid returns true if the keyword is in any configured category.
func IsValidZettelID ¶
IsValidZettelID checks if a string is a valid zettel ID
func ReadRawBlock ¶
ReadRawBlock reads the raw content of a task from its source file. Returns the task's own line plus all subsequent lines that are indented deeper (regardless of whether they are tasks or plain text).
func RecordCompletion ¶
RecordCompletion appends a LOG entry after the task line (backward-compatible wrapper).
func RecordStateTransition ¶ added in v0.12.0
RecordStateTransition appends a LOG entry after the task line.
func RenderMarkdownDescription ¶
RenderMarkdownDescription renders a task description with markdown formatting. Supports: bold, italic, strikethrough, inline code, URLs, and bullet markers.
func SetTaskDate ¶
SetTaskDate sets, updates, or removes scheduled/due dates on a task's source line. Empty string for scheduledAt/dueAt means no-op for that field. removeScheduled/removeDue=true removes the corresponding token.
func SortByPriority ¶
SortByPriority sorts tasks by their priority order Order: In Progress (1) -> Active (2) -> Someday (3) -> Completed (4) Uses stable sort to preserve relative order of equal-priority tasks
func StripLinePrefix ¶
StripLinePrefix strips leading whitespace and an optional bullet marker (-, *, +) followed by at least one space. Returns the content after the prefix and the byte offset where that content begins in the original line.
func SummarizeProjects ¶
SummarizeProjects summarizes task counts per project
func SyncFromJira ¶
SyncFromJira pulls open JIRA tickets assigned to the user, creates or updates corresponding tasks in karya, and handles disappeared tickets. Returns the count of issues found in JIRA.
func TruncateString ¶
TruncateString truncates s to maxWidth visible characters (ANSI-aware), appending "…" if truncated. Returns s unchanged if it fits.
func UpdateTaskLabels ¶
UpdateTaskLabels updates the tags on a task's line to match JIRA labels.
func UpdateTaskStatus ¶
UpdateTaskStatus updates the keyword of a task in its source file. It finds the line matching the task and replaces the keyword with the new one. Returns the updated line number, or an error if the task was not found.
If cfg is non-nil and newKeyword is a completed-category keyword, the task is blocked from completing while it has active or in-progress children — callers must resolve or reassign those first. Pass a nil cfg to skip this check (e.g. in tests that don't care about it).
Types ¶
type AgendaDay ¶
type AgendaDay struct {
Date time.Time
Items []AgendaItem
}
AgendaDay groups agenda items appearing on a single date.
func QueryAgenda ¶
QueryAgenda loads all tasks and returns agenda items within [start, end], grouped by day. Only tasks with scheduled or due dates are included. When includeOverdue is true, past-due items appear on today's date.
type AgendaItem ¶
type AgendaItem struct {
Task *Task
Date time.Time
HasTime bool
HasEnd bool
EndTime time.Time
IsOverdue bool
IsDeadline bool
Warning bool
ClockActive bool
Schedule *Schedule
IsCompleted bool
CompletedAt time.Time
TargetState string
}
AgendaItem represents a single entry in the agenda view.
type ClockEntry ¶
func ParseClockEntries ¶
func ParseClockEntries(t *Task) ([]ClockEntry, error)
ParseClockEntries reads a task's sub-lines and extracts CLOCK entries.
type ClockInArgs ¶
type ClockOutArgs ¶
type ClockProjectResult ¶
type ClockProjectResult struct {
Project string `json:"project" jsonschema:"project name"`
Total string `json:"total" jsonschema:"project total time as H:MM"`
Tasks []ClockTaskResult `json:"tasks" jsonschema:"per-task breakdown"`
}
type ClockResult ¶
type ClockTable ¶
type ClockTable struct {
GrandTotal time.Duration
Projects []ClockTableProject
}
func QueryClockTable ¶
QueryClockTable aggregates clock data for all tasks within [start, end].
type ClockTableEntry ¶
type ClockTableProject ¶
type ClockTableProject struct {
Project string
Total time.Duration
Entries []ClockTableEntry
}
type ClockTableResult ¶
type ClockTableResult struct {
GrandTotal string `json:"grand_total" jsonschema:"total time as H:MM"`
Projects []ClockProjectResult `json:"projects" jsonschema:"per-project breakdown"`
}
type ClockTaskResult ¶
type CompletionEntry ¶
func ParseCompletionEntries ¶
func ParseCompletionEntries(t *Task) ([]CompletionEntry, error)
ParseCompletionEntries reads a task's sub-lines and extracts COMPLETED entries. Kept for backward compatibility — prefers ParseStateTransitions for new code.
type CountTasksArgs ¶
type CountTasksResult ¶
type DatePicker ¶
type DatePicker struct {
Task *Task
Field DatePickerField
Cursor time.Time
Confirmed bool
Cancelled bool
ClearedScheduled bool
ClearedDue bool
ErrorMsg string
// Section navigation
Section pickerSection
// Time
HasTime bool
Hour int
Minute int
HasEndTime bool
EndHour int
EndMinute int
TimeFocus timeFocus
// Recurrence
HasRecurrence bool
RecurrenceMode RecurrenceMode
RecurrenceInterval int
RecurrenceUnit byte
RecFocus recurrenceFocus
// Warning
HasWarning bool
WarningDays int
}
func NewDatePicker ¶
func NewDatePicker(t *Task, field DatePickerField) *DatePicker
func (*DatePicker) Result ¶
func (dp *DatePicker) Result() (scheduledAt, dueAt string, removeScheduled, removeDue bool)
func (*DatePicker) Update ¶
func (dp *DatePicker) Update(key string)
func (*DatePicker) View ¶
func (dp *DatePicker) View(width int) string
type DatePickerField ¶
type DatePickerField int
const ( FieldScheduled DatePickerField = iota FieldDue )
type FilterTasksArgs ¶
type FilterTasksArgs struct {
Filter string `json:"filter" jsonschema:"filter expression (e.g., '>> alice' for assignee, '#urgent' for tag, '@2025-01-15' for date)"`
Project string `json:"project,omitempty" jsonschema:"optional project name to limit filter"`
ShowCompleted bool `json:"show_completed,omitempty" jsonschema:"whether to include completed tasks (default: false)"`
}
type FilterTasksResult ¶
type GetClockTableArgs ¶
type GetCycleTasksArgs ¶
type GetCycleTasksArgs struct {
Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}
type GetCycleTasksResult ¶
type GetDependenciesArgs ¶
type GetDependenciesResult ¶
type GetDependentsArgs ¶
type GetDependentsResult ¶
type GetKeywordsArgs ¶
type GetKeywordsArgs struct{}
type GetKeywordsResult ¶
type GetProjectsArgs ¶
type GetProjectsArgs struct{}
type GetProjectsResult ¶
type GetProjectsResult struct {
Projects []ProjectInfo `json:"projects" jsonschema:"list of projects with task counts"`
Count int `json:"count" jsonschema:"total number of projects"`
}
type GetTaskArgs ¶
type GetTaskByIDArgs ¶
type GetTaskByIDResult ¶
type GetTaskResult ¶
type KeywordEntry ¶
GetAllKeywordsFlat returns all configured keywords as a flat slice with category labels
func GetAllKeywordsFlat ¶
func GetAllKeywordsFlat(c *config.Config) []KeywordEntry
type ListTasksArgs ¶
type ListTasksResult ¶
type MCPServer ¶
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer wraps the MCP server with task operations
func NewMCPServer ¶
NewMCPServer creates a new MCP server for task operations
type ProjectInfo ¶
type RecurrenceMode ¶
type RecurrenceMode int
const ( RecurrenceFixed RecurrenceMode = iota // +N[dwmy] — advance from original date RecurrenceFromDone // .+N[dwmy] — advance from completion date RecurrenceNextFuture // ++N[dwmy] — next future occurrence from series )
type RecurrenceSpec ¶
type RecurrenceSpec struct {
Mode RecurrenceMode
Interval int
Unit byte // 'd', 'w', 'm', 'y'
}
type Schedule ¶
type Schedule struct {
Date time.Time
HasTime bool
EndTime time.Time
HasEnd bool
Recurrence *RecurrenceSpec
Warning *WarningSpec
Raw string
}
func ParseSchedule ¶
ParseSchedule parses a date token (the part after @s: or @d:) into a Schedule. Token grammar: DATE[TTIME][RECURRENCE][WARNING] DATE: YYYY-MM-DD TIME: THH:MM RECURRENCE: +N[dwmyb] | .+N[dwmyb] | ++N[dwmyb] WARNING: !Nd
func (*Schedule) ExpandOccurrences ¶
ExpandOccurrences generates all dates where this recurring schedule appears within [rangeStart, rangeEnd]. For non-recurring schedules, returns the single date if it falls within range. For .+ mode, only returns the stored date (cannot predict future). Range comparisons use calendar-day granularity so timed tasks are included when their day falls within the range, regardless of the time-of-day component.
func (*Schedule) FormatToken ¶
FormatToken reconstructs the date token string from the Schedule.
type ScheduleTaskArgs ¶
type ScheduleTaskArgs struct {
Project string `json:"project" jsonschema:"project name"`
Keyword string `json:"keyword" jsonschema:"current task keyword"`
Title string `json:"title" jsonschema:"task title to identify the task"`
ScheduledAt string `` /* 141-byte string literal not displayed */
DueAt string `json:"due_at,omitempty" jsonschema:"due date to set (same format). Omit to leave unchanged."`
RemoveScheduled bool `json:"remove_scheduled,omitempty" jsonschema:"if true, removes the existing scheduled date"`
RemoveDue bool `json:"remove_due,omitempty" jsonschema:"if true, removes the existing due date"`
}
type ScheduleTaskResult ¶
type SearchResult ¶
type SearchResult struct {
ZettelID string
Title string
LineNum int
Line string
Path string
Project string
}
SearchResult represents a search result from file content
func SearchInFile ¶
func SearchInFile(filePath, searchTerm string) []SearchResult
SearchInFile searches for a term within a file and returns matching lines
func SearchTasks ¶
SearchTasks searches for a term across all task files
type SearchResultInfo ¶
type SearchResultInfo struct {
Project string `json:"project" jsonschema:"project name"`
ZettelID string `json:"zettel_id,omitempty" jsonschema:"zettel ID (if structured mode)"`
Title string `json:"title" jsonschema:"file/zettel title"`
LineNum int `json:"line_num" jsonschema:"line number of the match"`
Line string `json:"line" jsonschema:"the matching line"`
Path string `json:"path" jsonschema:"file path"`
}
type SearchTasksArgs ¶
type SearchTasksResult ¶
type SearchTasksResult struct {
Results []SearchResultInfo `json:"results" jsonschema:"list of search results"`
Count int `json:"count" jsonschema:"total number of matches"`
}
type StateTransition ¶ added in v0.12.0
func ParseStateTransitions ¶ added in v0.12.0
func ParseStateTransitions(t *Task) ([]StateTransition, error)
ParseStateTransitions reads a task's sub-lines and extracts LOG and legacy COMPLETED entries.
type StatusPicker ¶
type StatusPicker struct {
Task *Task
Config *config.Config
Columns []statusColumn
ColCursor int
Confirmed bool
Cancelled bool
Selected string
}
func NewStatusPicker ¶
func NewStatusPicker(t *Task, c *config.Config) *StatusPicker
func (*StatusPicker) Update ¶
func (sp *StatusPicker) Update(key string)
func (*StatusPicker) View ¶
func (sp *StatusPicker) View(width int) string
type SyncJiraArgs ¶
type SyncJiraArgs struct{}
type SyncJiraResult ¶
type SyncJiraResult struct {
Message string `json:"message"`
}
type Task ¶
type Task struct {
Keyword string
ID string // Optional unique identifier [id]
Title string
Tags []string
References []string // IDs of tasks this task depends on (^id syntax)
ScheduledAt string // @date or @s:date (scheduled date)
DueAt string // @d:date (due date)
Assignee string
Project string
Zettel string
FilePath string // Original file path where this task was found
InCycle bool // True if this task participates in a circular dependency
IndentLevel int // Byte offset of first non-whitespace character in source line
LineNum int // 1-based line number in source file
Parent *Task // Parent task, nil for root tasks
Children []*Task // Child tasks nested under this task in the source file
}
Task represents a parsed task from a line
func FilterTasks ¶
FilterTasks applies field-specific filtering to a slice of tasks
func FindActiveClocks ¶
FindActiveClocks returns all tasks that have an open (running) clock entry.
func GetDependencies ¶
GetDependencies returns the tasks that the given task depends on
func GetDependents ¶
GetDependents returns the tasks that depend on the given task
func GetTaskByID ¶
GetTaskByID returns a task by its ID from a slice of tasks. Returns nil if id is empty or not found.
func GroupWithChildren ¶
GroupWithChildren reorders a sorted flat task list so each root task is immediately followed by its descendants (depth-first, children in file order). The flat list is unchanged in length; children are simply relocated adjacent to their parent rather than scattered by the sort.
func ListTasks ¶
ListTasks lists tasks for a project, filtering by showCompleted This includes tasks from both project files and the inbox file
func ProcessFile ¶
ProcessFile processes a README.md file and returns tasks
func (*Task) IsCompleted ¶
IsCompleted returns true if the task is completed
func (*Task) IsInProgress ¶
IsInProgress returns true if the task is in progress
func (*Task) PendingChildCount ¶
PendingChildCount returns the number of completed and total direct children.
type TaskInfo ¶
type TaskInfo struct {
Keyword string `json:"keyword" jsonschema:"task status keyword (e.g., TODO, DOING, DONE)"`
ID string `json:"id,omitempty" jsonschema:"task unique identifier"`
Title string `json:"title" jsonschema:"task title/description"`
Tags []string `json:"tags,omitempty" jsonschema:"task tags (without #)"`
References []string `json:"references,omitempty" jsonschema:"IDs of tasks this task depends on (^id syntax)"`
ScheduledAt string `json:"scheduled_at,omitempty" jsonschema:"scheduled date"`
DueAt string `json:"due_at,omitempty" jsonschema:"due date"`
Assignee string `json:"assignee,omitempty" jsonschema:"task assignee"`
Project string `json:"project" jsonschema:"project name"`
Zettel string `json:"zettel,omitempty" jsonschema:"zettel ID (if structured mode)"`
FilePath string `json:"file_path" jsonschema:"file path where task is defined"`
Priority int `json:"priority" jsonschema:"priority level (1=in_progress, 2=active, 3=someday, 4=completed)"`
Status string `json:"status" jsonschema:"status category (active, in_progress, completed, someday)"`
InCycle bool `json:"in_cycle,omitempty" jsonschema:"true if task participates in a circular dependency"`
ParentID string `json:"parent_id,omitempty" jsonschema:"ID of parent task (if this is a sub-task)"`
ChildCount int `json:"child_count,omitempty" jsonschema:"number of direct child tasks"`
RawContent string `json:"raw_content,omitempty" jsonschema:"raw file content of task and all indented lines below it"`
}
type UpdateTaskStatusArgs ¶
type UpdateTaskStatusArgs struct {
Project string `json:"project" jsonschema:"project name"`
Keyword string `json:"keyword" jsonschema:"current task keyword"`
Title string `json:"title" jsonschema:"task title to identify the task"`
NewKeyword string `json:"new_keyword" jsonschema:"new status keyword to set"`
}
type UpdateTaskStatusResult ¶
type UpdateTaskStatusResult struct {
Message string `json:"message" jsonschema:"status message"`
Success bool `json:"success" jsonschema:"whether the update succeeded"`
ValidKeywords map[string][]string `json:"valid_keywords" jsonschema:"valid keywords grouped by category (Active, InProgress, Completed, Someday)"`
}
type WarningSpec ¶
type WarningSpec struct {
Days int
}