| 348 | } |
| 349 | |
| 350 | func (t *ToolSet) updatePlanFromFile(ctx context.Context, params UpdatePlanFromFileArgs) (*tools.ToolCallResult, error) { |
| 351 | if params.Path == "" { |
| 352 | return tools.ResultError("path must not be empty"), nil |
| 353 | } |
| 354 | |
| 355 | content, err := readPlanFile(params.Path) |
| 356 | if err != nil { |
| 357 | return tools.ResultError(err.Error()), nil |
| 358 | } |
| 359 | if content == "" { |
| 360 | return tools.ResultError("file is empty; plan content must not be empty"), nil |
| 361 | } |
| 362 | |
| 363 | plan, err := t.storage.Upsert(ctx, UpsertRequest{ |
| 364 | Name: params.Name, |
| 365 | Content: &content, |
| 366 | Title: optStr(params.Title), |
| 367 | Author: optStr(params.Author), |
| 368 | Status: optStr(params.Status), |
| 369 | ExpectedRevision: params.LastKnownRevision, |
| 370 | }) |
| 371 | if err != nil { |
| 372 | return tools.ResultError(err.Error()), nil |
| 373 | } |
| 374 | |
| 375 | return tools.ResultJSON(plan), nil |
| 376 | } |
| 377 | |
| 378 | type ExportPlanToFileArgs struct { |
| 379 | Name string `json:"name" jsonschema:"The name of the plan to export."` |