From d413fe7c1c149aa46a4854be22a0a342a43011a2 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 11 Jul 2025 21:14:33 -0700 Subject: [PATCH] Add task summary --- mcp.go | 2 +- mcp_test.go | 2 +- taskcp.go | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mcp.go b/mcp.go index 32096b2..a6bc86a 100644 --- a/mcp.go +++ b/mcp.go @@ -147,4 +147,4 @@ func handleSetTaskFailure(s *Service, ctx context.Context, args setTaskFailureAr } return response, nil -} \ No newline at end of file +} diff --git a/mcp_test.go b/mcp_test.go index 80b419a..042a824 100644 --- a/mcp_test.go +++ b/mcp_test.go @@ -16,4 +16,4 @@ func TestRegisterMCPTools(t *testing.T) { t.Fatalf("Failed to register MCP tools: %v", err) } -} \ No newline at end of file +} diff --git a/taskcp.go b/taskcp.go index 21b4b35..486f204 100644 --- a/taskcp.go +++ b/taskcp.go @@ -46,6 +46,17 @@ type Task struct { completionCallback func(project *Project, task *Task) error } +type TaskSummary struct { + Title string `json:"title"` + State TaskState `json:"state"` + Error string `json:"error,omitempty"` + Notes string `json:"notes,omitempty"` +} + +type ProjectSummary struct { + Tasks []TaskSummary `json:"tasks"` +} + func New(mcpService string) *Service { return &Service{ Projects: map[string]*Project{}, @@ -166,6 +177,21 @@ func (p *Project) tasks() iter.Seq[*Task] { } } +func (p *Project) Summary() ProjectSummary { + var tasks []TaskSummary + for _, task := range p.Tasks { + if task.State != TaskStatePending { + tasks = append(tasks, TaskSummary{ + Title: task.Title, + State: task.State, + Error: task.Error, + Notes: task.Notes, + }) + } + } + return ProjectSummary{Tasks: tasks} +} + func (t *Task) SuccessPrompt() string { return fmt.Sprintf(`To mark this task as successful, use the MCP tool: %s.set_task_success(project_id="%s", task_id="%s", result="", notes="")`, @@ -186,3 +212,12 @@ func (t *Task) String() string { return string(json) } + +func (ps ProjectSummary) String() string { + json, err := json.MarshalIndent(ps, "", " ") + if err != nil { + panic(err) + } + + return string(json) +}