Documentation
¶
Overview ¶
Package improve implements the self-improvement loop (M9): /dream extracts durable facts from session traces and prunes stale memory, and /distill mines repeated tool sequences into skill, subagent, and command scaffolds.
Both halves are deliberately conservative. Dream summarizes with no tools attached, so it can never act on the trace it is reading. Distill only writes scaffolds — it never overwrites an existing file, so a generated artifact can always be edited by hand without a later run clobbering it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScaffoldCommand ¶
ScaffoldCommand writes a command scaffold under <root>/.opencode/command/.
func ScaffoldSkill ¶
ScaffoldSkill writes a SKILL.md scaffold under <root>/.claude/skills/<name>/, shaped so the SkillIndex (T-050) discovers it and BM25 (T-051) can rank it. It refuses to overwrite an existing scaffold.
Types ¶
type Dreamer ¶
type Dreamer struct {
// Provider is the model backend used for extraction.
Provider ports.Provider
// Model is the extraction model id ("<provider>/<model>").
Model string
}
Dreamer extracts durable facts from a session trace with a summarizing model.
type Entry ¶
type Entry struct {
Text string
UpdatedAt time.Time
// Pinned entries are never pruned, however old they get.
Pinned bool
}
Entry is one stored memory line with the metadata pruning needs.
func Prune ¶
func Prune(entries []Entry, now time.Time, policy PrunePolicy) (kept, pruned []Entry)
Prune splits entries into those to keep and those to drop. Entries are dropped when they exceed MaxAge, or when a newer entry says the same thing (case-insensitive). Pinned entries always survive. Input order is preserved among the kept entries.
type Kind ¶
type Kind int
Kind is the artifact a pattern is best distilled into.
func SuggestKind ¶
SuggestKind recommends what to distill a pattern into: a short but very frequent sequence is a command, a read-only sequence is a subagent, and anything that mutates the workspace is a skill.
type MineOptions ¶
type MineOptions struct {
// MinLength is the shortest sequence considered a pattern (default 2).
MinLength int
// MinRuns is how many distinct runs must contain it (default 2).
MinRuns int
// MaxLength caps the sequence length considered (default 8).
MaxLength int
}
MineOptions bounds the search. Zero values fall back to sane defaults rather than mining degenerate single-tool "patterns".
type Pattern ¶
type Pattern struct {
Tools []string
// Runs is the number of distinct runs the sequence appeared in.
Runs int
}
Pattern is a tool sequence that recurred across runs.
func MinePatterns ¶
func MinePatterns(rs []Run, opts MineOptions) []Pattern
MinePatterns finds contiguous tool sequences that appear in at least MinRuns distinct runs. Frequency counts *runs*, not occurrences: a sequence repeated twice inside one session is one habit, not two. Results are ordered longest-first, then by how many runs contain them.
type PrunePolicy ¶
PrunePolicy configures pruning. A zero MaxAge disables age-based pruning (deduplication still applies), so a misconfigured policy cannot silently wipe a project's memory.