ProposePlan returns a tool that presents a Markdown plan file from the workspace for user review.
(options ProposePlanOptions)
| 29 | // ProposePlan returns a tool that presents a Markdown plan file from the |
| 30 | // workspace for user review. |
| 31 | func ProposePlan(options ProposePlanOptions) fantasy.AgentTool { |
| 32 | return fantasy.NewAgentTool( |
| 33 | "propose_plan", |
| 34 | "Present a Markdown plan file from the workspace for user review. "+ |
| 35 | "The file must already exist with a .md extension. Use write_file to create it or edit_files to refine it before calling this tool. "+ |
| 36 | "Pass the absolute file path to the plan. Important: use the chat-specific absolute plan path, not a generic path like PLAN.md in the home directory. "+ |
| 37 | "The tool reads the content from the workspace.", |
| 38 | func(ctx context.Context, args ProposePlanArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) { |
| 39 | if options.IsPlanTurn { |
| 40 | planPath, err := resolvePlanTurnPath(ctx, options.ResolvePlanPath) |
| 41 | if err != nil { |
| 42 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 43 | } |
| 44 | path := strings.TrimSpace(args.Path) |
| 45 | switch { |
| 46 | case path == "": |
| 47 | args.Path = planPath |
| 48 | case path != planPath: |
| 49 | return fantasy.NewTextErrorResponse("during plan turns, propose_plan path must be " + planPath), nil |
| 50 | default: |
| 51 | args.Path = path |
| 52 | } |
| 53 | } |
| 54 | if options.GetWorkspaceConn == nil { |
| 55 | return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil |
| 56 | } |
| 57 | if options.StoreFile == nil { |
| 58 | return fantasy.NewTextErrorResponse("file storage is not configured"), nil |
| 59 | } |
| 60 | conn, err := options.GetWorkspaceConn(ctx) |
| 61 | if err != nil { |
| 62 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 63 | } |
| 64 | return executeProposePlanTool(ctx, conn, args, options.ResolvePlanPath, options.StoreFile) |
| 65 | }, |
| 66 | ) |
| 67 | } |
| 68 | |
| 69 | func executeProposePlanTool( |
| 70 | ctx context.Context, |