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
- func BuildPlanPrompt(goal, instructions, fileTree, recentLog, memCtx, existingTasks, request string, ...) string
- func BuildPrompt(goal, instructions, fileTree, recentLog, memCtx, existingTasks string, ...) string
- func CategoryLabel(c Category) string
- func CleanRequest(s string) (string, error)
- func EffortLabel(e Effort) string
- func NormalizeIdeas(r *Result, limit int)
- func NormalizePlan(r *Result, limit int)
- func PriorityFor(e Effort) int
- func RoleFor(c Category) pm.AgentRole
- type Category
- type Effort
- type Ledger
- type Placement
- type Result
- type Suggestion
Constants ¶
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 ¶
CategoryLabel returns a human-readable category label.
func CleanRequest ¶ added in v0.0.3
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 ¶
EffortLabel returns a human-readable effort label.
func NormalizeIdeas ¶ added in v0.0.3
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
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
PriorityFor converts an idea's effort to a task priority (1 = highest). Smaller efforts get slightly higher priority to keep things moving.
Types ¶
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 plan given a Placement runs at the priority it names rather than at the tail, and each of its tasks also waits for the tasks it names.
A Ledger is not safe for concurrent use.
func (*Ledger) Apply ¶ added in v0.0.3
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
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 Placement ¶ added in v0.0.7
type Placement struct {
// Priority, when above 0, is the priority every task of the plan takes.
Priority int
// After are the tasks every task of the plan waits for, as they were when
// the plan was asked for. One deleted since — or whose ID now names a
// different task — is dropped rather than followed.
After []*pm.Task
}
Placement is where a plan's tasks join the run queue when the person who asked for the plan has said so. Decompose on the Tasks tab (Task 20441) plans one task typed with a priority and the tasks it waits for, and every task of the plan inherits both: the work it splits up was to run at that priority, and none of it could start before those tasks were finished. The zero value is the default: the queue's tail, in plan order, each task waiting only for the plan's own earlier ones.
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.
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.