kanban

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCreated      = "created"
	EventStatusChange = "status_changed"
	EventCommented    = "commented"
	EventCompleted    = "completed"
	EventBlocked      = "blocked"
	EventUnblocked    = "unblocked"
	EventClaimed      = "claimed"
	EventHeartbeat    = "heartbeat"
	EventTimeout      = "timeout"
	EventCrash        = "crash"
)

EventType constants

View Source
const (
	RunStatusRunning   = "running"
	RunStatusCompleted = "completed"
	RunStatusFailed    = "failed"
	RunStatusCrashed   = "crashed"
	RunStatusTimedOut  = "timed_out"
)

RunStatus constants

Variables

ValidStatuses contains all valid task statuses

Functions

func GenerateRunID

func GenerateRunID() string

GenerateRunID generates a new unique run ID

func IsValidStatus

func IsValidStatus(s TaskStatus) bool

IsValidStatus checks if a status is valid

Types

type AddParentLink struct {
	ParentID string
}

AddParentLink is a helper to add a parent link during task creation

type BurndownPoint added in v0.4.8

type BurndownPoint struct {
	Date      string `json:"date"`
	Total     int    `json:"total"`     // Total tasks at start of day
	Remaining int    `json:"remaining"` // Tasks not done
	Completed int    `json:"completed"` // Tasks completed that day
	Added     int    `json:"added"`     // Tasks added that day
}

BurndownPoint represents a point in the burndown chart

type Comment

type Comment struct {
	ID        string    `json:"id"`
	TaskID    string    `json:"task_id"`
	Author    string    `json:"author"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
}

Comment represents a task comment

type Dispatcher

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

Dispatcher manages task dispatch and lifecycle

func NewDispatcher

func NewDispatcher(db *KanbanDB) *Dispatcher

NewDispatcher creates a new dispatcher

func (*Dispatcher) IsCircuitBroken

func (d *Dispatcher) IsCircuitBroken() bool

IsCircuitBroken returns true if the dispatcher has too many consecutive failures

func (*Dispatcher) ResetFailures

func (d *Dispatcher) ResetFailures()

ResetFailures resets the consecutive failure counter

func (*Dispatcher) SetMaxConsecutiveFailures

func (d *Dispatcher) SetMaxConsecutiveFailures(max int)

SetMaxConsecutiveFailures sets the maximum consecutive failures before circuit break

func (*Dispatcher) SetMaxRetries

func (d *Dispatcher) SetMaxRetries(max int)

SetMaxRetries sets the maximum retries

func (*Dispatcher) SetTickInterval

func (d *Dispatcher) SetTickInterval(interval time.Duration)

SetTickInterval sets the tick interval

func (*Dispatcher) Start

func (d *Dispatcher) Start()

Start starts the dispatcher background loop

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Stop stops the dispatcher

func (*Dispatcher) Tick

func (d *Dispatcher) Tick() error

Tick performs one dispatch cycle

type Event

type Event struct {
	ID        string    `json:"id"`
	TaskID    string    `json:"task_id"`
	EventType string    `json:"event_type"` // created/status_changed/commented/completed/blocked/unblocked
	Payload   string    `json:"payload"`    // JSON
	CreatedAt time.Time `json:"created_at"`
}

Event represents a task event for notifications

type KanbanDB

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

KanbanDB manages the kanban SQLite database

func NewKanbanDB

func NewKanbanDB(path string) (*KanbanDB, error)

NewKanbanDB creates a new KanbanDB instance

func (*KanbanDB) AddComment

func (kdb *KanbanDB) AddComment(comment *Comment) error

AddComment adds a comment to a task

func (*KanbanDB) AddEvent

func (kdb *KanbanDB) AddEvent(event *Event) error

AddEvent adds an event to the event log

func (kdb *KanbanDB) AddLink(parentID, childID string) error

AddLink adds a parent-child link

func (*KanbanDB) AreAllParentsDone

func (kdb *KanbanDB) AreAllParentsDone(taskID string) (bool, error)

AreAllParentsDone checks if all parent tasks are done

func (*KanbanDB) ClaimTask

func (kdb *KanbanDB) ClaimTask(taskID, assignee, runID string) (bool, error)

ClaimTask atomically claims a task (CAS: ready → running)

func (*KanbanDB) Close

func (kdb *KanbanDB) Close() error

Close closes the database connection

func (*KanbanDB) CreateRun

func (kdb *KanbanDB) CreateRun(run *Run) error

CreateRun creates a new task run

func (*KanbanDB) CreateTask

func (kdb *KanbanDB) CreateTask(task *Task) error

CreateTask creates a new task

func (*KanbanDB) DeleteTask

func (kdb *KanbanDB) DeleteTask(id string) error

DeleteTask deletes a task by ID

func (*KanbanDB) GetBoard

func (kdb *KanbanDB) GetBoard(tenant string) (map[TaskStatus][]*Task, error)

GetBoard returns tasks grouped by status for board view

func (*KanbanDB) GetBurndownData added in v0.4.8

func (kdb *KanbanDB) GetBurndownData(tenant string, days int) ([]BurndownPoint, error)

GetBurndownData returns burndown chart data for the last N days

func (*KanbanDB) GetChildren

func (kdb *KanbanDB) GetChildren(taskID string) ([]*Task, error)

GetChildren gets all child tasks of a task

func (*KanbanDB) GetCurrentRun

func (kdb *KanbanDB) GetCurrentRun(taskID string) (*Run, error)

GetCurrentRun gets the current running task for a task

func (*KanbanDB) GetParents

func (kdb *KanbanDB) GetParents(taskID string) ([]*Task, error)

GetParents gets all parent tasks of a task

func (*KanbanDB) GetReadyTasks

func (kdb *KanbanDB) GetReadyTasks() ([]*Task, error)

GetReadyTasks gets all ready tasks (for dispatcher)

func (*KanbanDB) GetRunningTasks

func (kdb *KanbanDB) GetRunningTasks() ([]*Task, error)

GetRunningTasks gets all running tasks (for dispatcher)

func (*KanbanDB) GetStats

func (kdb *KanbanDB) GetStats(tenant string) (map[TaskStatus]int, error)

GetStats returns task counts by status

func (*KanbanDB) GetTask

func (kdb *KanbanDB) GetTask(id string) (*Task, error)

GetTask retrieves a task by ID

func (*KanbanDB) GetTaskWithMeta

func (kdb *KanbanDB) GetTaskWithMeta(id string) (*Task, error)

GetTaskWithMeta gets a task with metadata (parent count, comment count, etc.)

func (*KanbanDB) GetThroughputStats added in v0.4.8

func (kdb *KanbanDB) GetThroughputStats(tenant string, days int) (*ThroughputStats, error)

GetThroughputStats returns task throughput statistics

func (*KanbanDB) GetTodoTasks

func (kdb *KanbanDB) GetTodoTasks() ([]*Task, error)

GetTodoTasks gets all todo tasks (for dispatcher)

func (*KanbanDB) Init

func (kdb *KanbanDB) Init() error

Init initializes the database schema

func (*KanbanDB) ListComments

func (kdb *KanbanDB) ListComments(taskID string) ([]*Comment, error)

ListComments lists comments for a task

func (*KanbanDB) ListEvents

func (kdb *KanbanDB) ListEvents(taskID string, since time.Time) ([]*Event, error)

ListEvents lists events for a task since a given time

func (*KanbanDB) ListRuns

func (kdb *KanbanDB) ListRuns(taskID string) ([]*Run, error)

ListRuns lists all runs for a task

func (*KanbanDB) ListTasks

func (kdb *KanbanDB) ListTasks(filter TaskFilter) ([]*Task, error)

ListTasks lists tasks with optional filters

func (kdb *KanbanDB) RemoveLink(parentID, childID string) error

RemoveLink removes a parent-child link

func (*KanbanDB) UpdateRun

func (kdb *KanbanDB) UpdateRun(run *Run) error

UpdateRun updates a task run

func (*KanbanDB) UpdateTask

func (kdb *KanbanDB) UpdateTask(task *Task) error

UpdateTask updates a task

func (*KanbanDB) UpdateTaskStatus

func (kdb *KanbanDB) UpdateTaskStatus(id, newStatus, summary string) error

UpdateTaskStatus updates a task's status

type Manager

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

Manager provides high-level kanban operations

func NewManager

func NewManager(homeDir string) (*Manager, error)

NewManager creates a new kanban manager

func (*Manager) AddComment

func (m *Manager) AddComment(taskID, author, body string) (*Comment, error)

AddComment adds a comment to a task

func (m *Manager) AddLink(parentID, childID string) error

AddLink adds a parent-child dependency

func (*Manager) ArchiveTask

func (m *Manager) ArchiveTask(id string) (*Task, error)

ArchiveTask moves a done task to archived

func (*Manager) BlockTask

func (m *Manager) BlockTask(id, reason string) (*Task, error)

BlockTask marks a running task as blocked

func (*Manager) ClaimTask

func (m *Manager) ClaimTask(id, assignee string) (*Task, error)

ClaimTask atomically claims a ready task for running

func (*Manager) Close

func (m *Manager) Close() error

Close closes the kanban system

func (*Manager) CompleteTask

func (m *Manager) CompleteTask(id, summary string) (*Task, error)

CompleteTask marks a running task as done

func (*Manager) CreateTask

func (m *Manager) CreateTask(title, body, assignee string, opts ...TaskOption) (*Task, error)

CreateTask creates a new task

func (*Manager) CreateTaskWithParent

func (m *Manager) CreateTaskWithParent(title, body, assignee, parentID string, opts ...TaskOption) (*Task, error)

CreateTaskWithParent creates a task and links it to a parent

func (*Manager) DecomposeGoal added in v0.4.13

func (m *Manager) DecomposeGoal(ctx context.Context, goalID, goalTitle, goalDescription string, prov provider.Provider) ([]*Task, error)

DecomposeGoal uses LLM to break down a goal into a set of actionable kanban tasks

func (*Manager) DeleteTask

func (m *Manager) DeleteTask(id string) error

DeleteTask deletes a task

func (*Manager) GetBoard

func (m *Manager) GetBoard(tenant string) (map[TaskStatus][]*Task, error)

GetBoard returns the kanban board view

func (*Manager) GetBurndownData added in v0.4.8

func (m *Manager) GetBurndownData(tenant string, days int) ([]BurndownPoint, error)

GetBurndownData returns burndown chart data for a time period

func (*Manager) GetChildren

func (m *Manager) GetChildren(taskID string) ([]*Task, error)

GetChildren gets all child tasks

func (*Manager) GetDB

func (m *Manager) GetDB() *KanbanDB

GetDB returns the database (for testing)

func (*Manager) GetDispatcher

func (m *Manager) GetDispatcher() *Dispatcher

GetDispatcher returns the dispatcher (for testing)

func (*Manager) GetParents

func (m *Manager) GetParents(taskID string) ([]*Task, error)

GetParents gets all parent tasks

func (*Manager) GetStats

func (m *Manager) GetStats(tenant string) (map[TaskStatus]int, error)

GetStats returns task statistics

func (*Manager) GetTask

func (m *Manager) GetTask(id string) (*Task, error)

GetTask retrieves a task by ID with metadata

func (*Manager) GetThroughputStats added in v0.4.8

func (m *Manager) GetThroughputStats(tenant string, days int) (*ThroughputStats, error)

GetThroughputStats returns task throughput statistics

func (*Manager) Heartbeat

func (m *Manager) Heartbeat(id string) error

Heartbeat updates the task's updated_at timestamp (indicating the agent is alive)

func (*Manager) Init

func (m *Manager) Init() error

Init initializes the kanban system

func (*Manager) ListComments

func (m *Manager) ListComments(taskID string) ([]*Comment, error)

ListComments lists comments for a task

func (*Manager) ListRuns

func (m *Manager) ListRuns(taskID string) ([]*Run, error)

ListRuns lists execution runs for a task

func (*Manager) ListTasks

func (m *Manager) ListTasks(filter TaskFilter) ([]*Task, error)

ListTasks lists tasks with filters

func (m *Manager) RemoveLink(parentID, childID string) error

RemoveLink removes a parent-child dependency

func (*Manager) SplitTask added in v0.4.8

func (m *Manager) SplitTask(ctx context.Context, id string, prov provider.Provider) ([]*Task, error)

SplitTask uses LLM to split a task into subtasks

func (*Manager) StartTask

func (m *Manager) StartTask(id string) (*Task, error)

StartTask moves a task from triage/todo to ready

func (*Manager) TriageTask

func (m *Manager) TriageTask(ctx context.Context, id string, prov provider.Provider) (*Task, error)

TriageTask uses LLM to refine a triage task into detailed requirements

func (*Manager) UnblockTask

func (m *Manager) UnblockTask(id string) (*Task, error)

UnblockTask moves a blocked task back to ready

func (*Manager) UpdateTask

func (m *Manager) UpdateTask(id string, updates map[string]interface{}) (*Task, error)

UpdateTask updates a task

func (*Manager) UpdateTaskWithPID

func (m *Manager) UpdateTaskWithPID(id string, runID string, pid int) error

UpdateTaskWithPID updates a task's current run with a PID

type Run

type Run struct {
	ID         string     `json:"id"`
	TaskID     string     `json:"task_id"`
	Status     string     `json:"status"` // running/completed/failed/crashed/timed_out
	PID        int        `json:"pid"`
	RetryCount int        `json:"retry_count"`
	StartedAt  time.Time  `json:"started_at"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
	Summary    string     `json:"summary"`
	Result     string     `json:"result"`
}

Run represents a task execution run

type Task

type Task struct {
	ID                string     `json:"id"`
	Title             string     `json:"title"`
	Body              string     `json:"body"`
	Assignee          string     `json:"assignee"`
	Status            TaskStatus `json:"status"`
	Priority          int        `json:"priority"` // 0=low, 1=medium, 2=high, 3=critical
	Tenant            string     `json:"tenant"`
	Workspace         string     `json:"workspace"`
	Skills            []string   `json:"skills"`
	MaxRuntimeSeconds int        `json:"max_runtime_seconds"`
	IdempotencyKey    string     `json:"idempotency_key"`
	CurrentRunID      string     `json:"current_run_id"`
	CreatedAt         time.Time  `json:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at"`

	// Time tracking fields
	DueDate        *time.Time `json:"due_date,omitempty"`        // Deadline
	EstimatedHours float64    `json:"estimated_hours,omitempty"` // Estimated work hours
	ActualHours    float64    `json:"actual_hours,omitempty"`    // Actual work hours
	StartedAt      *time.Time `json:"started_at,omitempty"`      // When task was started
	CompletedAt    *time.Time `json:"completed_at,omitempty"`    // When task was completed

	// Goal association
	GoalID string `json:"goal_id,omitempty"` // Associated goal ID

	// Virtual fields (not stored in DB)
	ParentCount    int `json:"parent_count,omitempty"`
	CommentCount   int `json:"comment_count,omitempty"`
	ChildDoneCount int `json:"child_done_count,omitempty"`
	ChildCount     int `json:"child_count,omitempty"`
}

Task represents a kanban task

type TaskFilter

type TaskFilter struct {
	Status    []TaskStatus `json:"status,omitempty"`
	Assignee  string       `json:"assignee,omitempty"`
	Tenant    string       `json:"tenant,omitempty"`
	Priority  *int         `json:"priority,omitempty"`
	Search    string       `json:"search,omitempty"`
	GoalID    string       `json:"goal_id,omitempty"`    // Filter by associated goal
	DueBefore *time.Time   `json:"due_before,omitempty"` // Filter by deadline
	DueAfter  *time.Time   `json:"due_after,omitempty"`  // Filter by deadline
	Limit     int          `json:"limit,omitempty"`
	Offset    int          `json:"offset,omitempty"`
}

TaskFilter represents filter criteria for listing tasks

type TaskOption

type TaskOption func(*Task)

TaskOption is a functional option for creating tasks

func WithAssignee

func WithAssignee(a string) TaskOption

WithAssignee sets the task assignee

func WithBody

func WithBody(b string) TaskOption

WithBody sets the task body

func WithIdempotencyKey

func WithIdempotencyKey(k string) TaskOption

WithIdempotencyKey sets the task idempotency key

func WithMaxRuntime

func WithMaxRuntime(sec int) TaskOption

WithMaxRuntime sets the task max runtime in seconds

func WithParentID

func WithParentID(parentID string) TaskOption

WithParentID creates an option to link to a parent task

func WithPriority

func WithPriority(p int) TaskOption

WithPriority sets the task priority

func WithSkills

func WithSkills(s []string) TaskOption

WithSkills sets the task skills

func WithTenant

func WithTenant(t string) TaskOption

WithTenant sets the task tenant

func WithWorkspace

func WithWorkspace(w string) TaskOption

WithWorkspace sets the task workspace

type TaskStatus

type TaskStatus string

TaskStatus represents the status of a task

const (
	StatusTriage   TaskStatus = "triage"
	StatusTodo     TaskStatus = "todo"
	StatusReady    TaskStatus = "ready"
	StatusRunning  TaskStatus = "running"
	StatusBlocked  TaskStatus = "blocked"
	StatusDone     TaskStatus = "done"
	StatusArchived TaskStatus = "archived"
)

type ThroughputStats added in v0.4.8

type ThroughputStats struct {
	TotalCreated     int     `json:"total_created"`           // Total tasks created
	TotalCompleted   int     `json:"total_completed"`         // Total tasks completed
	AverageLeadTime  float64 `json:"average_lead_time_hours"` // Average time from creation to completion
	ThroughputPerDay float64 `json:"throughput_per_day"`      // Average tasks completed per day
}

ThroughputStats represents throughput statistics

Jump to

Keyboard shortcuts

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