| 381 | } |
| 382 | |
| 383 | func (t *ToolSet) exportPlanToFile(ctx context.Context, params ExportPlanToFileArgs) (*tools.ToolCallResult, error) { |
| 384 | if params.Path == "" { |
| 385 | return tools.ResultError("path must not be empty"), nil |
| 386 | } |
| 387 | |
| 388 | plan, ok, err := t.storage.Get(ctx, params.Name) |
| 389 | if err != nil { |
| 390 | return tools.ResultError(err.Error()), nil |
| 391 | } |
| 392 | if !ok { |
| 393 | return tools.ResultError(fmt.Sprintf("plan %q not found", params.Name)), nil |
| 394 | } |
| 395 | |
| 396 | if err := writePlanFile(params.Path, plan.Content); err != nil { |
| 397 | return tools.ResultError(err.Error()), nil |
| 398 | } |
| 399 | |
| 400 | return tools.ResultJSON(ExportResult{ |
| 401 | Name: params.Name, |
| 402 | Path: params.Path, |
| 403 | Title: plan.Title, |
| 404 | Status: plan.Status, |
| 405 | Revision: plan.Revision, |
| 406 | BytesWritten: len(plan.Content), |
| 407 | }), nil |
| 408 | } |
| 409 | |
| 410 | type SetPlanStatusArgs struct { |
| 411 | Name string `json:"name" jsonschema:"The name of the plan whose status to set."` |