writePlanFile writes plan content to a file for export_plan_to_file. It creates any missing parent directories and writes atomically (temp + rename), so a reader never sees a partial export and the agent can point at a fresh path without first creating its directory.
(path, content string)
| 545 | // so a reader never sees a partial export and the agent can point at a fresh |
| 546 | // path without first creating its directory. |
| 547 | func writePlanFile(path, content string) error { |
| 548 | clean := filepath.Clean(path) |
| 549 | |
| 550 | if info, err := os.Stat(clean); err == nil && info.IsDir() { |
| 551 | return fmt.Errorf("path %q is a directory, not a file", path) |
| 552 | } |
| 553 | if dir := filepath.Dir(clean); dir != "" { |
| 554 | if err := os.MkdirAll(dir, 0o700); err != nil { |
| 555 | return fmt.Errorf("creating directory for plan file: %w", err) |
| 556 | } |
| 557 | } |
| 558 | if err := atomicfile.Write(clean, strings.NewReader(content), 0o600); err != nil { |
| 559 | return fmt.Errorf("writing plan file: %w", err) |
| 560 | } |
| 561 | return nil |
| 562 | } |
| 563 | |
| 564 | func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error) { |
| 565 | return []tools.Tool{ |
no test coverage detected