Task.String() returns JSON, add Data field

This commit is contained in:
Ian Gulliver
2025-07-05 21:58:34 -07:00
parent eda5e0cf73
commit 778acf833d

View File

@@ -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="<error message>", notes="<optional 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)
}