Documentation
¶
Overview ¶
Package promptstats tracks per-task prompt outcomes to learn which prompt patterns correlate with success vs failure. Records are appended to .cloop/prompt-stats.jsonl as JSONL entries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdaptiveHint ¶
AdaptiveHint returns a short advisory string to prepend to a prompt based on historical outcomes for tasks with similar titles. Returns "" when there is no relevant history (< 2 matching records).
func Append ¶
Append writes a single record to the JSONL stats file, creating the file and parent directory as needed.
func FeedbackHint ¶
func FeedbackHint(records []FeedbackRecord, taskTitle string) string
FeedbackHint returns a short advisory string derived from human ratings of similar tasks. Returns "" when there are fewer than 2 matching records. High-rated tasks (4-5) indicate an approach that worked well; low-rated ones (1-2) flag patterns to avoid.
func HashPrompt ¶
HashPrompt returns a 12-char hex prefix of the SHA-256 of the prompt. This is used as a compact fingerprint for matching similar prompts.
Types ¶
type FeedbackRecord ¶
FeedbackRecord is a minimal view of pkg/feedback.Record used here to avoid an import cycle. Callers should pass feedback records cast to this type.
type HashStats ¶
HashStats aggregates outcomes for a single prompt hash.
func TopPerforming ¶
TopPerforming returns HashStats sorted by success rate descending, limited to hashes with at least minTotal executions.
func (HashStats) FailureRate ¶
FailureRate returns the fraction of executions that failed (0.0 – 1.0).
func (HashStats) SuccessRate ¶
SuccessRate returns the fraction of executions that succeeded (0.0 – 1.0).
type Record ¶
type Record struct {
TaskTitle string `json:"task_title"`
PromptHash string `json:"prompt_hash"`
Outcome string `json:"outcome"` // "done", "failed", "skipped"
DurationMs int64 `json:"duration_ms"` // wall-clock ms for the task
}
Record is a single prompt outcome entry written after a task completes.