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 ¶
var ErrDuplicateContent = errors.New("todo: duplicate content")
ErrDuplicateContent indicates repeated content.
var ErrEmptyContent = errors.New("todo: empty content")
ErrEmptyContent indicates an item with blank content.
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 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 ¶
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) Tool ¶
func (t *TodoWriteTool) Tool() *tools.Tool
TodoTool returns a *tools.Tool wrapper for integration with M23 pipeline.