loop: add todo checklist
This should improve Sketch's executive function and user communication.
diff --git a/loop/agent.go b/loop/agent.go
index f9450ab..e77f588 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -126,6 +126,8 @@
FirstMessageIndex() int
CurrentStateName() string
+ // CurrentTodoContent returns the current todo list data as JSON, or empty string if no todos exist
+ CurrentTodoContent() string
}
type CodingAgentMessageType string
@@ -180,6 +182,9 @@
// This is useful for subconversations that generate output that shouldn't be shown to the user.
HideOutput bool `json:"hide_output,omitempty"`
+ // TodoContent contains the agent's todo file content when it has changed
+ TodoContent *string `json:"todo_content,omitempty"`
+
Idx int `json:"idx"`
}
@@ -457,6 +462,17 @@
return a.stateMachine.CurrentState().String()
}
+// CurrentTodoContent returns the current todo list data as JSON.
+// It returns an empty string if no todos exist.
+func (a *Agent) CurrentTodoContent() string {
+ todoPath := claudetool.TodoFilePath(a.config.SessionID)
+ content, err := os.ReadFile(todoPath)
+ if err != nil {
+ return ""
+ }
+ return string(content)
+}
+
func (a *Agent) URL() string { return a.url }
// Title returns the current title of the conversation.
@@ -988,7 +1004,7 @@
convo.Tools = []*llm.Tool{
bashTool, claudetool.Keyword,
- claudetool.Think, a.titleTool(), a.precommitTool(), makeDoneTool(a.codereview),
+ claudetool.Think, claudetool.TodoRead, claudetool.TodoWrite, a.titleTool(), a.precommitTool(), makeDoneTool(a.codereview),
a.codereview.Tool(), claudetool.AboutSketch,
}
@@ -1395,8 +1411,9 @@
// Transition to running tool state
a.stateMachine.Transition(ctx, StateRunningTool, "Executing requested tool")
- // Add working directory to context for tool execution
+ // Add working directory and session ID to context for tool execution
ctx = claudetool.WithWorkingDir(ctx, a.workingDir)
+ ctx = claudetool.WithSessionID(ctx, a.config.SessionID)
// Execute the tools
var err error