whatif

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package whatif implements scenario-based what-if planning for cloop. It applies a natural-language mutation to an in-memory copy of the plan, re-runs velocity forecasting, and feeds the before/after diff to the AI to narrate timeline, risk, and mitigation consequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNarrativePrompt

func BuildNarrativePrompt(report *Report) string

BuildNarrativePrompt constructs the AI prompt for narrating what-if consequences.

func FormatMarkdown

func FormatMarkdown(r *Report) string

FormatMarkdown renders a complete Markdown what-if report suitable for stdout.

Types

type Report

type Report struct {
	Scenario string `json:"scenario"`

	// Before state
	BeforeForecast *forecast.Forecast `json:"before_forecast"`

	// After (mutated) state
	MutatedPlan   *pm.Plan           `json:"mutated_plan"`
	AfterForecast *forecast.Forecast `json:"after_forecast"`

	// Structural diff
	TasksAdded   []*pm.Task   `json:"tasks_added,omitempty"`
	TasksRemoved []*pm.Task   `json:"tasks_removed,omitempty"`
	TasksChanged []TaskChange `json:"tasks_changed,omitempty"`

	// AI narrative
	Narrative string `json:"narrative"`

	// Removed tasks flagged by planedit
	RemovedTaskWarnings []*pm.Task `json:"removed_task_warnings,omitempty"`
}

Report holds the full what-if analysis — before/after forecasts, structural diff, and the AI narrative.

func Run

func Run(ctx context.Context, prov provider.Provider, opts provider.Options, s *state.ProjectState, scenario string, streamFn func(string)) (*Report, error)

Run executes the full what-if pipeline:

  1. Clone plan.
  2. Apply mutation via AI (using planedit).
  3. Build before/after forecasts (no AI).
  4. Build diff.
  5. Generate AI narrative (streamed via streamFn).

type TaskChange

type TaskChange struct {
	TaskID    int    `json:"task_id"`
	TaskTitle string `json:"task_title"`
	Field     string `json:"field"`
	Before    string `json:"before"`
	After     string `json:"after"`
}

TaskChange describes a single field-level change between the original and mutated plan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL