Documentation
¶
Overview ¶
Package planedit provides AI-powered natural-language plan mutation. It allows users to describe changes to the task plan in plain English and have the AI apply those changes, returning a modified plan JSON that can be reviewed and confirmed before writing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEditPrompt ¶
BuildEditPrompt constructs the AI prompt for natural-language plan mutation. It embeds the full plan JSON and the user instruction, asking the AI to return a modified plan JSON with only the requested changes applied.
Types ¶
type EditResult ¶
type EditResult struct {
// ModifiedPlan is the new plan produced by the AI.
ModifiedPlan *pm.Plan
// RemovedTasks contains tasks that the AI tried to remove.
// These are surfaced separately so callers can require explicit confirmation.
RemovedTasks []*pm.Task
}
EditResult holds the modified plan and metadata about what changed.
func EditPlan ¶
func EditPlan(ctx context.Context, p provider.Provider, opts provider.Options, plan *pm.Plan, instruction string) (*EditResult, error)
EditPlan calls the AI provider with the edit prompt and returns an EditResult. The caller is responsible for reviewing and confirming the changes before writing the modified plan to disk.
func ParseEditResponse ¶
func ParseEditResponse(original *pm.Plan, aiResponse string) (*EditResult, error)
ParseEditResponse parses the AI response (which should be a plan JSON) and returns an EditResult that describes what changed relative to the original plan.
The function is lenient about JSON embedded in prose: it searches for the outermost { ... } block if the response contains surrounding text.
Validation:
- The modified plan must have at least as many tasks as the original (removed tasks are allowed but surfaced in EditResult.RemovedTasks).
- Tasks that exist in the original keep their non-structural fields (artifact path, result, timing, etc.) — only the "editable" fields from the AI response are applied.