From 778acf833dba539fb6a53b576c3ca00a7491963a Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 5 Jul 2025 21:58:34 -0700 Subject: [PATCH] Task.String() returns JSON, add Data field --- taskcp.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/taskcp.go b/taskcp.go index ccf64df..ed64622 100644 --- a/taskcp.go +++ b/taskcp.go @@ -1,6 +1,7 @@ package taskcp import ( + "encoding/json" "fmt" "iter" "strings" @@ -30,12 +31,13 @@ const ( ) type Task struct { - ID string `json:"id"` - State TaskState `json:"-"` - Instructions string `json:"instructions"` - Result string `json:"-"` - Error string `json:"-"` - Notes string `json:"-"` + ID string `json:"id"` + State TaskState `json:"-"` + Instructions string `json:"instructions"` + Data map[string]any `json:"data,omitempty"` + Result string `json:"-"` + Error string `json:"-"` + Notes string `json:"-"` projectID string mcpService string @@ -169,3 +171,12 @@ func (t *Task) FailurePrompt() string { %s.set_task_failure(project_id="%s", task_id="%s", error="", notes="")`, t.mcpService, t.projectID, t.ID) } + +func (t *Task) String() string { + json, err := json.MarshalIndent(t, "", " ") + if err != nil { + panic(err) + } + + return string(json) +}