suggest

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: 8 Imported by: 0

Documentation

Overview

Package suggest implements AI-driven feature idea generation. It brainstorms concrete feature suggestions for a project and returns them in a structured format suitable for interactive user review.

Index

Constants

View Source
const (
	// DefaultCount is how many ideas a brainstorm produces when not told.
	// A plan has no default: left unset, it is as long as the request needs.
	DefaultCount = 5
	// MaxCount caps one generation: the ideas a hub will brainstorm at once,
	// and the tasks any plan may have.
	MaxCount = 20
	// MaxRequestRunes bounds a request to plan. It is generous for a page of
	// prose, and it keeps the request — which reaches the executor as a
	// command-line argument — far below the kernel's per-argument limit.
	MaxRequestRunes = 8000
)

Variables

This section is empty.

Functions

func BuildPlanPrompt added in v0.0.3

func BuildPlanPrompt(goal, instructions, fileTree, recentLog, memCtx, existingTasks, request string, count int) string

BuildPlanPrompt constructs the prompt that breaks request into a plan of tasks. count > 0 asks for exactly that many; 0 leaves the number to the request — as many tasks as it genuinely needs, up to MaxCount.

func BuildPrompt

func BuildPrompt(goal, instructions, fileTree, recentLog, memCtx, existingTasks string, count int) string

BuildPrompt constructs the prompt for generating feature suggestions.

func CategoryLabel

func CategoryLabel(c Category) string

CategoryLabel returns a human-readable category label.

func CleanRequest added in v0.0.3

func CleanRequest(s string) (string, error)

CleanRequest trims a request to plan and checks that it can be handed to the planner. The request travels to the executor as an argument, and argv cannot carry a NUL byte, so one is refused here with a reason rather than failing later as an opaque exec error.

func EffortLabel

func EffortLabel(e Effort) string

EffortLabel returns a human-readable effort label.

func NormalizeIdeas added in v0.0.3

func NormalizeIdeas(r *Result, limit int)

NormalizeIdeas is NormalizePlan for a brainstorm: untitled ideas are dropped, at most limit are kept when limit > 0, and the rest are numbered 1..N. Ideas are independent, so any dependencies are discarded. Unique IDs are what lets the dashboard accept one idea by naming it.

func NormalizePlan added in v0.0.3

func NormalizePlan(r *Result, limit int)

NormalizePlan makes a generated plan safe to act on, whatever the model wrote. Tasks without a title are dropped and at most limit are kept (MaxCount when limit is 0 or larger). The rest are renumbered 1..N in the order given, and every DependsOn is translated to the new numbers and kept only where it names an earlier task — so each edge points backwards and the dependencies cannot form a cycle, by construction.

Idempotent: normalizing a normalized plan changes nothing, which lets the hub re-check what a device's cloop sent it without disturbing it.

func PriorityFor added in v0.0.3

func PriorityFor(e Effort) int

PriorityFor converts an idea's effort to a task priority (1 = highest). Smaller efforts get slightly higher priority to keep things moving.

func RoleFor added in v0.0.3

func RoleFor(c Category) pm.AgentRole

RoleFor maps a suggestion's category to the agent role best suited to it.

Types

type Category

type Category string

Category classifies the type of a suggestion.

const (
	CategoryFeature     Category = "feature"
	CategoryUX          Category = "ux"
	CategoryPerformance Category = "performance"
	CategorySecurity    Category = "security"
	CategoryDX          Category = "dx" // developer experience
	CategoryIntegration Category = "integration"
	CategoryDocs        Category = "docs"
)

type Effort

type Effort string

Effort is a rough implementation size estimate.

const (
	EffortXS Effort = "xs" // < 1 hour
	EffortS  Effort = "s"  // 1–4 hours
	EffortM  Effort = "m"  // 4–16 hours
	EffortL  Effort = "l"  // 1–5 days
	EffortXL Effort = "xl" // > 1 week
)

type Ledger added in v0.0.3

type Ledger struct {
	// contains filtered or unexported fields
}

Ledger turns reviewed suggestions into tasks and remembers which ones it has turned, so one generation's proposals can be accepted a few at a time.

For brainstormed ideas that is bookkeeping: each becomes an independent task. For a plan it is what keeps the plan intact when its tasks are accepted one by one, out of order, or not all of them — each task still waits for the work the plan put before it:

  • Tasks join the end of the run queue in plan order, so a plan accepted in one go runs top to bottom.
  • A task whose prerequisite was never added depends on that prerequisite's own prerequisites instead, transitively, so skipping a step does not cut the chain.
  • A task added before one of its prerequisites gains the dependency when the prerequisite arrives, provided it has not started yet.

A Ledger is not safe for concurrent use.

func NewLedger added in v0.0.3

func NewLedger(r *Result) *Ledger

NewLedger returns an empty ledger for one generation's result.

func (*Ledger) Apply added in v0.0.3

func (l *Ledger) Apply(plan *pm.Plan, picked []*Suggestion) []*pm.Task

Apply appends picked to plan as pending tasks and returns the tasks it added, in the order added. A suggestion that already became a task still in the plan is skipped, so repeating a request is harmless.

func (*Ledger) Clone added in v0.0.3

func (l *Ledger) Clone() *Ledger

Clone returns an independent copy. Apply a clone, and keep it only once the plan it changed has been saved.

func (*Ledger) Pending added in v0.0.3

func (l *Ledger) Pending(all []*Suggestion) []*Suggestion

Pending returns the suggestions in all that have not become tasks yet.

type Result

type Result struct {
	Suggestions []*Suggestion `json:"suggestions"`
	Summary     string        `json:"summary"`
	// Request is what the user asked to have planned. Non-empty means the
	// suggestions are the tasks of one plan, in order, rather than loose ideas.
	Request string `json:"request,omitempty"`
}

Result holds all AI-generated suggestions and an optional summary.

func Generate

func Generate(ctx context.Context, p provider.Provider, prompt string, opts provider.Options) (*Result, error)

Generate calls the provider to brainstorm feature suggestions. opts should carry the project's WorkDir: it is where a harness provider runs and where the mock provider finds its scripted responses.

func GeneratePlan added in v0.0.3

func GeneratePlan(ctx context.Context, p provider.Provider, prompt string, opts provider.Options, request string, count int) (*Result, error)

GeneratePlan calls the provider to break request into a plan: count tasks, or as many as the request needs when count is 0. The result is normalized (see NormalizePlan) and carries the request, which marks it as a plan.

func Parse

func Parse(output string) (*Result, error)

Parse extracts a Result from the AI's JSON response.

type Suggestion

type Suggestion struct {
	ID          int      `json:"id"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
	Rationale   string   `json:"rationale"`
	Category    Category `json:"category"`
	Effort      Effort   `json:"effort"`
	// DependsOn names the earlier tasks of the same plan, by ID, that must be
	// finished before this one can start. Always empty for brainstormed ideas.
	DependsOn []int `json:"depends_on,omitempty"`
}

Suggestion is a single AI-brainstormed feature idea, or one task of a plan.

Jump to

Keyboard shortcuts

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