todo

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Todo normalization enforces constraints beyond schema: nonblank trimmed content, unique content, and at most one in_progress item without parallel mode. It also provides counts for all three states.

Package todo implements whole-list replacement, matching core/todo. Each todo/write replaces the current list with last-write-wins semantics. TodoWriteTool validates model JSON and writes a session event. Reads use FoldTodoWrite so incremental appends and cold replay agree.

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateContent = errors.New("todo: duplicate content")

ErrDuplicateContent indicates repeated content.

View Source
var ErrEmptyContent = errors.New("todo: empty content")

ErrEmptyContent indicates an item with blank content.

View Source
var ErrMultipleActive = errors.New("todo: more than one in_progress")

ErrMultipleActive indicates multiple in_progress items without parallel mode.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	Pending    int
	InProgress int
	Completed  int
}

Counts holds counts for the three states.

func Count

func Count(items []TodoItem) Counts

Count counts items in each state.

type TodoItem

type TodoItem struct {
	// ID optionally tracks items across replacements; upstream does not require IDs.
	ID string `json:"id,omitempty"`
	// Content describes the todo.
	Content string `json:"content"`
	// Status is the three-state status.
	Status TodoStatus `json:"status,omitempty"`
	// Done provides two-state compatibility when Status is empty.
	Done bool `json:"done,omitempty"`
}

func Current

func Current(log *session.SessionLog) []TodoItem

Current derives the latest list through folding, preferring three-state entries.

func Normalize

func Normalize(items []TodoItem, allowParallel bool) ([]TodoItem, error)

Normalize trims and validates todos. Blank content returns ErrEmptyContent, duplicates return ErrDuplicateContent, and multiple active items without allowParallel return ErrMultipleActive.

func (TodoItem) ResolvedStatus

func (it TodoItem) ResolvedStatus() TodoStatus

ResolvedStatus prefers Status, otherwise derives it from Done.

type TodoStatus

type TodoStatus string

TodoStatus is the three-state todo lifecycle matching upstream TodoItem.status.

const (
	StatusPending    TodoStatus = "pending"     // Not started.
	StatusInProgress TodoStatus = "in_progress" // In progress.
	StatusCompleted  TodoStatus = "completed"   // Completed.
)

func (TodoStatus) Valid

func (s TodoStatus) Valid() bool

Valid checks whether the status is one of the three valid states.

type TodoWriteTool

type TodoWriteTool struct {

	// AllowParallel permits multiple in_progress items; false defaults to sequential work.
	AllowParallel bool
	// contains filtered or unexported fields
}

TodoWriteTool implements todo_write. Input contains items with optional IDs and legacy done flags. Each call completely replaces the list and appends a todo/write event to SessionLog.

func NewTodoWriteTool

func NewTodoWriteTool(sl *session.SessionLog) *TodoWriteTool

NewTodoWriteTool creates a todo_write tool.

func (*TodoWriteTool) Description

func (t *TodoWriteTool) Description() string

Description returns the tool description.

func (*TodoWriteTool) Execute

func (t *TodoWriteTool) Execute(ctx context.Context, input map[string]any) (any, error)

Execute replaces the todo list and writes its event.

func (*TodoWriteTool) Name

func (t *TodoWriteTool) Name() string

Name returns the tool name.

func (*TodoWriteTool) Tool

func (t *TodoWriteTool) Tool() *tools.Tool

TodoTool returns a *tools.Tool wrapper for integration with M23 pipeline.

Jump to

Keyboard shortcuts

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