learning

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package learning implements cross-session AI learning memory for cloop. After each PM run the AI distills key outcomes, failure patterns, and project conventions into .cloop/memory.md. On subsequent runs this memory is injected into every task execution prompt so the AI improves over time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distill

func Distill(ctx context.Context, p provider.Provider, model string, plan *pm.Plan) (string, error)

Distill asks the AI to summarise what worked, what failed, and any recurring patterns from the just-completed PM plan. Returns a markdown document.

func FormatForPrompt

func FormatForPrompt(workDir string) string

FormatForPrompt wraps the memory content for injection into a task prompt. Returns empty string if memory is empty.

func LoadMemory

func LoadMemory(workDir string) string

LoadMemory reads the project memory from .cloop/memory.md. Returns empty string if no memory file exists yet, or if the file exceeds the in-prompt size cap (memoryFileMaxBytes) — in which case prompts run without injected memory until the next SaveMemory call rewrites the file at a healthy size, rather than risk blowing token budgets by injecting an arbitrarily large blob into every task prompt.

func SaveMemory

func SaveMemory(workDir, summary string) error

SaveMemory writes the distilled summary to .cloop/memory.md. Each call appends a dated section so history accumulates over runs.

The whole read-modify-write is serialised by saveMu — concurrent callers would otherwise each load the same baseline and the second writer would silently drop the first writer's session. The final write is atomic (tmp → fsync → rename), so a crash mid-write can never leave a truncated memory.md that destroys all accumulated history.

Types

This section is empty.

Jump to

Keyboard shortcuts

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