Add task summary
This commit is contained in:
2
mcp.go
2
mcp.go
@@ -147,4 +147,4 @@ func handleSetTaskFailure(s *Service, ctx context.Context, args setTaskFailureAr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ func TestRegisterMCPTools(t *testing.T) {
|
|||||||
t.Fatalf("Failed to register MCP tools: %v", err)
|
t.Fatalf("Failed to register MCP tools: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
35
taskcp.go
35
taskcp.go
@@ -46,6 +46,17 @@ type Task struct {
|
|||||||
completionCallback func(project *Project, task *Task) error
|
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 {
|
func New(mcpService string) *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
Projects: map[string]*Project{},
|
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 {
|
func (t *Task) SuccessPrompt() string {
|
||||||
return fmt.Sprintf(`To mark this task as successful, use the MCP tool:
|
return fmt.Sprintf(`To mark this task as successful, use the MCP tool:
|
||||||
%s.set_task_success(project_id="%s", task_id="%s", result="<your result>", notes="<optional notes>")`,
|
%s.set_task_success(project_id="%s", task_id="%s", result="<your result>", notes="<optional notes>")`,
|
||||||
@@ -186,3 +212,12 @@ func (t *Task) String() string {
|
|||||||
|
|
||||||
return string(json)
|
return string(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ps ProjectSummary) String() string {
|
||||||
|
json, err := json.MarshalIndent(ps, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(json)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user