task

package
v0.0.0-...-0c5fcde Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func FindFiles(c *config.Config, project string) ([]string, error)

FindFiles finds README.md files in project directories (structured mode) or all .md files in the project tree (unstructured mode)

func GetAllKeywords

func GetAllKeywords(c *config.Config) map[string][]string

GetAllKeywords returns all configured keywords grouped by category

func GetZettelTitle

func GetZettelTitle(zetDir, zetID string) (string, error)

GetZettelTitle gets the title of a zettel from its README.md file

func IsValidZettelID

func IsValidZettelID(id string) bool

IsValidZettelID checks if a string is a valid zettel ID

func RenderMarkdownDescription

func RenderMarkdownDescription(description string, taskColor lipgloss.Style) string

RenderMarkdownDescription renders a task description with markdown formatting It supports bold (**text**), italic (*text*), strikethrough (~~text~~), and inline code (`code`) The raw markdown syntax is hidden in the output

Color choices: - Bold text: Uses bright white color to make it stand out - Italic text: Preserves the original text color but adds italic styling - Strikethrough text: Preserves the original text color but adds strikethrough styling - Inline code: Uses black text on white background for clear distinction

func SortByPriority

func SortByPriority(tasks []*Task, c *config.Config)

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 SummarizeProjects

func SummarizeProjects(c *config.Config) (map[string]int, error)

SummarizeProjects summarizes task counts per project

func UpdateTaskStatus

func UpdateTaskStatus(t *Task, newKeyword string) error

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.

Types

type CountTasksArgs

type CountTasksArgs struct {
	Project       string `json:"project,omitempty" jsonschema:"optional project name to filter count"`
	ShowCompleted bool   `json:"show_completed,omitempty" jsonschema:"whether to include completed tasks (default: false)"`
}

type CountTasksResult

type CountTasksResult struct {
	Count    int            `json:"count" jsonschema:"total number of tasks"`
	ByStatus map[string]int `json:"by_status" jsonschema:"count of tasks by status category"`
}

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 FilterTasksResult struct {
	Tasks []TaskInfo `json:"tasks" jsonschema:"list of filtered tasks"`
	Count int        `json:"count" jsonschema:"total number of tasks matching filter"`
}

type GetCycleTasksArgs

type GetCycleTasksArgs struct {
	Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}

type GetCycleTasksResult

type GetCycleTasksResult struct {
	Tasks []TaskInfo `json:"tasks" jsonschema:"tasks involved in circular dependencies"`
	Count int        `json:"count" jsonschema:"number of tasks in cycles"`
}

type GetDependenciesArgs

type GetDependenciesArgs struct {
	ID      string `json:"id" jsonschema:"task ID to get dependencies for"`
	Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}

type GetDependenciesResult

type GetDependenciesResult struct {
	Task         *TaskInfo  `json:"task,omitempty" jsonschema:"the task being queried"`
	Dependencies []TaskInfo `json:"dependencies" jsonschema:"tasks that this task depends on (referenced via ^id)"`
	Count        int        `json:"count" jsonschema:"number of dependencies"`
}

type GetDependentsArgs

type GetDependentsArgs struct {
	ID      string `json:"id" jsonschema:"task ID to get dependents for"`
	Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}

type GetDependentsResult

type GetDependentsResult struct {
	Task       *TaskInfo  `json:"task,omitempty" jsonschema:"the task being queried"`
	Dependents []TaskInfo `json:"dependents" jsonschema:"tasks that depend on this task (have ^id reference to it)"`
	Count      int        `json:"count" jsonschema:"number of dependents"`
}

type GetKeywordsArgs

type GetKeywordsArgs struct{}

type GetKeywordsResult

type GetKeywordsResult struct {
	Keywords   map[string][]string `json:"keywords" jsonschema:"keywords grouped by category (Active, InProgress, Completed, Someday)"`
	Categories []string            `json:"categories" jsonschema:"list of category names"`
}

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 GetTaskArgs struct {
	Project string `json:"project" jsonschema:"project name"`
	Keyword string `json:"keyword" jsonschema:"task keyword"`
	Title   string `json:"title" jsonschema:"task title (partial match supported)"`
}

type GetTaskByIDArgs

type GetTaskByIDArgs struct {
	ID      string `json:"id" jsonschema:"task ID to look up"`
	Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}

type GetTaskByIDResult

type GetTaskByIDResult struct {
	Task  *TaskInfo `json:"task,omitempty" jsonschema:"the matching task"`
	Found bool      `json:"found" jsonschema:"whether a task with this ID was found"`
}

type GetTaskResult

type GetTaskResult struct {
	Task  *TaskInfo `json:"task,omitempty" jsonschema:"the matching task"`
	Found bool      `json:"found" jsonschema:"whether a matching task was found"`
}

type KeywordEntry

type KeywordEntry struct {
	Keyword  string
	Category string
}

GetAllKeywordsFlat returns all configured keywords as a flat slice with category labels

func GetAllKeywordsFlat

func GetAllKeywordsFlat(c *config.Config) []KeywordEntry

type ListTasksArgs

type ListTasksArgs struct {
	Project       string `json:"project,omitempty" jsonschema:"project name to filter tasks (optional, empty for all projects)"`
	ShowCompleted bool   `json:"show_completed,omitempty" jsonschema:"whether to include completed tasks (default: false)"`
}

type ListTasksResult

type ListTasksResult struct {
	Tasks []TaskInfo `json:"tasks" jsonschema:"list of tasks"`
	Count int        `json:"count" jsonschema:"total number of tasks returned"`
}

type MCPServer

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

MCPServer wraps the MCP server with task operations

func NewMCPServer

func NewMCPServer(cfg *config.Config) *MCPServer

NewMCPServer creates a new MCP server for task operations

func (*MCPServer) Run

func (s *MCPServer) Run(ctx context.Context) error

Run starts the MCP server on stdio transport

type ProjectInfo

type ProjectInfo struct {
	Name      string `json:"name" jsonschema:"project name"`
	TaskCount int    `json:"task_count" jsonschema:"number of active tasks in the project"`
}

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

func SearchTasks(c *config.Config, project string, searchTerm string) ([]SearchResult, error)

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 SearchTasksArgs struct {
	Pattern string `json:"pattern" jsonschema:"search pattern (case-insensitive substring match across all task fields)"`
	Project string `json:"project,omitempty" jsonschema:"optional project name to limit search"`
}

type SearchTasksResult

type SearchTasksResult struct {
	Results []SearchResultInfo `json:"results" jsonschema:"list of search results"`
	Count   int                `json:"count" jsonschema:"total number of matches"`
}

type Task

type Task struct {
	Keyword     string
	ID          string // Optional unique identifier [id]
	Title       string
	Tag         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
}

Task represents a parsed task from a line

func FilterTasks

func FilterTasks(tasks []*Task, filterString string) []*Task

FilterTasks applies field-specific filtering to a slice of tasks

func GetDependencies

func GetDependencies(tasks []*Task, t *Task) []*Task

GetDependencies returns the tasks that the given task depends on

func GetDependents

func GetDependents(tasks []*Task, t *Task) []*Task

GetDependents returns the tasks that depend on the given task

func GetTaskByID

func GetTaskByID(tasks []*Task, id string) *Task

GetTaskByID returns a task by its ID from a slice of tasks. Returns nil if id is empty or not found.

func ListTasks

func ListTasks(c *config.Config, project string, showCompleted bool) ([]*Task, error)

ListTasks lists tasks for a project, filtering by showCompleted

func ParseLine

func ParseLine(c *config.Config, line, project, zettel, filePath string) *Task

ParseLine parses a task line and returns a Task

func ProcessFile

func ProcessFile(c *config.Config, filePath string) ([]*Task, error)

ProcessFile processes a README.md file and returns tasks

func (*Task) IsActive

func (t *Task) IsActive(c *config.Config) bool

IsActive returns true if the task is active (not completed)

func (*Task) IsCompleted

func (t *Task) IsCompleted(c *config.Config) bool

IsCompleted returns true if the task is completed

func (*Task) IsInProgress

func (t *Task) IsInProgress(c *config.Config) bool

IsInProgress returns true if the task is in progress

func (*Task) IsSomeday

func (t *Task) IsSomeday(c *config.Config) bool

IsSomeday returns true if the task is a someday/maybe task

func (*Task) Priority

func (t *Task) Priority(c *config.Config) int

Priority returns the sorting priority of the task Lower numbers indicate higher priority 1 = In Progress, 2 = Active, 3 = Someday, 4 = Completed

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"`
	Tag         string   `json:"tag,omitempty" jsonschema:"task tag (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"`
}

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)"`
}

Jump to

Keyboard shortcuts

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