forecast

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Overview

Package forecast provides AI-powered project completion forecasting for cloop. It computes velocity-based completion dates with confidence intervals, renders an ASCII burn-down chart, and streams an AI narrative forecast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForecastPrompt

func ForecastPrompt(f *Forecast) string

ForecastPrompt builds the AI prompt for a detailed completion forecast.

func Generate

func Generate(ctx context.Context, p provider.Provider, f *Forecast, model string, streamFn func(string)) (string, error)

Generate calls the AI provider to stream a forecast narrative. The streamed output is written to streamFn as it arrives. Returns the full text.

Types

type BurnPoint

type BurnPoint struct {
	Date      time.Time
	Remaining int
}

BurnPoint is one data point for the burn-down chart.

type Forecast

type Forecast struct {
	Goal        string
	GeneratedAt time.Time

	// Task counts
	TotalTasks      int
	DoneTasks       int
	SkippedTasks    int
	FailedTasks     int
	PendingTasks    int
	BlockedTasks    int
	InProgressTasks int

	// Velocity metrics (time-based: tasks/day)
	BaseVelocityPerDay float64 // tasks/day (baseline)
	AvgTaskDuration    time.Duration
	ProjectStartDate   time.Time

	// Velocity metrics (minute-based: actual vs estimated)
	VelocityRatio       float64 // sum(actual_minutes)/sum(estimated_minutes); 1.0 if no data
	AvgEstimatedMinutes float64 // average EstimatedMinutes across all tasks with estimates
	MinuteDataPoints    int     // number of tasks with both estimated and actual minutes

	// Scenarios
	Optimistic  Scenario
	Expected    Scenario
	Pessimistic Scenario

	// Historical burn-down data (one point per completed task, chronological)
	BurnPoints []BurnPoint

	// Per-task schedule projections for remaining work
	TaskWindows []TaskWindow

	// AI-generated narrative
	AIText string
}

Forecast holds the full forecasting output.

func Build

func Build(s *state.ProjectState) *Forecast

Build computes a Forecast from the current project state. No AI call is made here.

func (*Forecast) BurndownChart

func (f *Forecast) BurndownChart(width, height int) string

BurndownChart renders an ASCII burn-down chart (width × height characters).

func (*Forecast) CompletionPct

func (f *Forecast) CompletionPct() int

CompletionPct returns percent of tasks finished (done + skipped).

func (*Forecast) GanttTable

func (f *Forecast) GanttTable() string

GanttTable renders the per-task schedule projection as an ASCII table.

type Scenario

type Scenario struct {
	Label          string
	VelocityFactor float64 // multiplier applied to baseline velocity
	DaysRemaining  float64 // -1 = cannot compute
	CompletionDate time.Time
	Confidence     string // "high" | "medium" | "low"
}

Scenario represents one completion estimate (optimistic / expected / pessimistic).

type TaskWindow

type TaskWindow struct {
	TaskID           int       `json:"task_id"`
	Title            string    `json:"title"`
	Status           string    `json:"status"`
	Priority         int       `json:"priority"`
	EstimatedMinutes int       `json:"estimated_minutes"`
	AdjustedMinutes  int       `json:"adjusted_minutes"` // estimated * VelocityRatio
	ProjectedStart   time.Time `json:"projected_start"`
	ProjectedEnd     time.Time `json:"projected_end"`
}

TaskWindow holds per-task schedule projection for the Gantt table.

Jump to

Keyboard shortcuts

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