tasks

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tasks implements a file-authoritative task ledger for TinyMem.

The task system follows these principles: 1. tinyTasks.md is the sole source of truth for task state 2. TinyMem never infers task completion 3. Memory entries are fully rebuildable from the file 4. If file and memory disagree, file wins 5. Memory never stores subtask text or implementation detail

The system supports: - Top-level checkbox tasks with nested subtasks - Stable task identification based on section and position - One-way sync from file to memory - Drift detection and recovery

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateInertTaskFile added in v0.5.2

func CreateInertTaskFile(projectPath string) error

CreateInertTaskFile creates the canonical inert tinyTasks.md template This file is intentionally non-authorizing - humans must edit it to add tasks

func ShouldAutoCreateTaskFile added in v0.5.2

func ShouldAutoCreateTaskFile(input string) bool

ShouldAutoCreateTaskFile detects if a request implies multi-step work

Types

type Service

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

Service handles task operations

func NewService

func NewService(db *storage.DB, memoryService *memory.Service, projectID string, manager *TaskManager) *Service

NewService creates a new task service

func (*Service) CanActOnTask added in v0.1.23

func (s *Service) CanActOnTask(taskID string, query string) (bool, error)

CanActOnTask checks if an action can be performed on a task based on safety rules

func (*Service) CanCreateNewTask added in v0.1.23

func (s *Service) CanCreateNewTask(query string) bool

CanCreateNewTask checks if a new task can be created based on the query

func (*Service) CreateOrUpdateTask

func (s *Service) CreateOrUpdateTask(task *Task) error

CreateOrUpdateTask creates or updates a task in memory

func (*Service) DeleteTask

func (s *Service) DeleteTask(key string) error

DeleteTask removes a task from memory

func (*Service) DetectAndRecoverDrift

func (s *Service) DetectAndRecoverDrift(filePath string) error

DetectAndRecoverDrift checks for differences between file and memory and recovers if needed

func (*Service) GetAllTasks

func (s *Service) GetAllTasks() ([]*memory.Memory, error)

GetAllTasks retrieves all task memories for the project

func (*Service) GetTaskByKey

func (s *Service) GetTaskByKey(key string) (*memory.Memory, error)

GetTaskByKey retrieves a task by its key

func (*Service) GetTaskStatus

func (s *Service) GetTaskStatus(projectPath string) (map[string]interface{}, error)

GetTaskStatus returns a summary of task status

func (*Service) HasExplicitTaskContinuationIntent added in v0.1.23

func (s *Service) HasExplicitTaskContinuationIntent(query string) bool

HasExplicitTaskContinuationIntent checks if the query explicitly requests task continuation

func (*Service) SyncTasks

func (s *Service) SyncTasks(projectPath string) error

SyncTasks performs synchronization of tasks from file to memory

func (*Service) SyncTasksFromFile

func (s *Service) SyncTasksFromFile(filePath string) error

SyncTasksFromFile synchronizes tasks from the tinyTasks.md file to memory

type SubtaskSpec added in v0.8.0

type SubtaskSpec struct {
	Title     string
	Completed bool
}

SubtaskSpec describes a single subtask line.

type Task

type Task struct {
	ID           string            `json:"id"`
	Title        string            `json:"title"`
	Section      string            `json:"section"`
	Index        int               `json:"index"`
	StepsTotal   int               `json:"steps_total"`
	StepsDone    int               `json:"steps_done"`
	Completed    bool              `json:"completed"`
	State        TaskState         `json:"state"`
	Mode         TaskMode          `json:"mode"`
	LastSeenHash string            `json:"last_seen_hash"`
	FilePath     string            `json:"file_path"`
	LastUpdated  string            `json:"last_updated"`
	ExtraFields  map[string]string `json:"extra_fields,omitempty"` // For future extensibility
}

Task represents a parsed task from tinyTasks.md

func ParseTasks

func ParseTasks(r io.Reader) ([]*Task, error)

ParseTasks parses the tinyTasks.md file and returns a list of tasks

type TaskDefinition added in v0.8.0

type TaskDefinition struct {
	Section  string
	Title    string
	Subtasks []SubtaskSpec
}

TaskDefinition describes a task the manager will add to the file.

type TaskDocument added in v0.8.0

type TaskDocument struct {
	Lines              []string
	HasTrailingNewline bool
	TaskOrder          []*TaskRange
	Ranges             map[string]*TaskRange
	SectionEnds        map[string]int
	SectionHeaders     map[string]int
	SectionCounts      map[string]int
}

TaskDocument represents the parsed structure of tinyTasks.md.

func (*TaskDocument) CloneLines added in v0.8.0

func (doc *TaskDocument) CloneLines() []string

func (*TaskDocument) HasSection added in v0.8.0

func (doc *TaskDocument) HasSection(name string) bool

func (*TaskDocument) TaskRangeByID added in v0.8.0

func (doc *TaskDocument) TaskRangeByID(id string) (*TaskRange, bool)

func (*TaskDocument) Tasks added in v0.8.0

func (doc *TaskDocument) Tasks() []*Task

type TaskManager added in v0.8.0

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

TaskManager centralizes every interaction with tinyTasks.md so that the server can treat the file as the single source of truth without letting other modules read or mutate it directly.

func NewTaskManager added in v0.8.0

func NewTaskManager(path string) *TaskManager

NewTaskManager returns a manager bound to the provided tinyTasks.md path.

func (*TaskManager) AddTask added in v0.8.0

func (tm *TaskManager) AddTask(def TaskDefinition) (*Task, error)

AddTask appends a new task to the file. If the file does not exist, it is created with the canonical inert template before the addition.

func (*TaskManager) Complete added in v0.8.0

func (tm *TaskManager) Complete(taskID string) (*Task, error)

Complete marks every checkbox within a task as finished.

func (*TaskManager) CreateInertFile added in v0.8.0

func (tm *TaskManager) CreateInertFile() error

CreateInertFile writes the canonical inert tinyTasks.md template.

func (*TaskManager) Exists added in v0.8.0

func (tm *TaskManager) Exists() (bool, error)

Exists reports whether the task file is present.

func (*TaskManager) Hash added in v0.8.0

func (tm *TaskManager) Hash() (string, error)

Hash returns the SHA256 hash of the task file.

func (*TaskManager) List added in v0.8.0

func (tm *TaskManager) List() ([]*Task, error)

List returns the tasks in file order.

func (*TaskManager) Load added in v0.8.0

func (tm *TaskManager) Load() (*TaskDocument, error)

Load parses the task file into a document structure.

func (*TaskManager) Path added in v0.8.0

func (tm *TaskManager) Path() string

Path returns the configured file path.

func (*TaskManager) UpdateTask added in v0.8.0

func (tm *TaskManager) UpdateTask(taskID string, update TaskUpdate) (*Task, error)

UpdateTask mutates the title or subtasks for a given task.

type TaskMode added in v0.1.23

type TaskMode string

TaskMode represents how the task should be treated

const (
	TaskModeDormant TaskMode = "dormant" // Default - read-only, no execution
	TaskModeActive  TaskMode = "active"  // Only when explicitly requested by user
)

type TaskRange added in v0.8.0

type TaskRange struct {
	Task            *Task
	Start           int
	End             int
	CheckboxIndices []int
}

TaskRange describes the lines occupied by a single top-level task.

type TaskSafetyEnforcer added in v0.1.23

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

TaskSafetyEnforcer enforces the safety rules for task operations

func NewTaskSafetyEnforcer added in v0.1.23

func NewTaskSafetyEnforcer() *TaskSafetyEnforcer

NewTaskSafetyEnforcer creates a new safety enforcer

func (*TaskSafetyEnforcer) CanActOnTask added in v0.1.23

func (e *TaskSafetyEnforcer) CanActOnTask(task *Task, query string) bool

CanActOnTask determines if an action can be performed on a task

func (*TaskSafetyEnforcer) CanCreateNewTask added in v0.1.23

func (e *TaskSafetyEnforcer) CanCreateNewTask(query string) bool

CanCreateNewTask determines if a new task can be created without affecting existing tasks

func (*TaskSafetyEnforcer) HasExplicitTaskContinuationIntent added in v0.1.23

func (e *TaskSafetyEnforcer) HasExplicitTaskContinuationIntent(query string) bool

HasExplicitTaskContinuationIntent checks if the user explicitly requested to continue tasks

type TaskState added in v0.1.23

type TaskState string

TaskState represents the state of a task

const (
	TaskStateOpen      TaskState = "open"
	TaskStateCompleted TaskState = "completed"
)

type TaskUpdate added in v0.8.0

type TaskUpdate struct {
	Title    *string
	Subtasks *[]SubtaskSpec
}

TaskUpdate describes a mutation to an existing task.

Jump to

Keyboard shortcuts

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