@samfp/pi-lesson-extractor
v0.1.0
Published
Pi extension that extracts reusable problem-solving patterns from session transcripts — retry loops, error→fix pairs, user corrections, and confirmed approaches.
Maintainers
Readme
pi-lesson-extractor
A pi extension that automatically extracts reusable problem-solving patterns from session transcripts.
What it does
Runs pattern detection on session shutdown and session switch (/new), extracting:
- Retry loop detection — same tool fails then succeeds with a different approach
- Error→fix pair detection — error messages mapped to their resolutions
- User correction detection — user messages that corrected agent behavior
- Confirmation detection — user messages that validated an approach (positive signal)
Candidates accumulate with confidence scores and auto-promote to permanent pi-memory lessons when they reach threshold.
Installation
pi install @samfp/pi-lesson-extractorRequires @samfp/pi-memory as a peer dependency (for lesson promotion).
How it works
Lifecycle
session_before_switch— runs fast heuristic pattern detection on current session entries before/newor/resumesession_shutdown— same extraction on process exitsession_start— checks for pending candidates, runs auto-promotion pipeline, shows notification count
Auto-promotion pipeline
Candidates that meet promotion criteria (high confidence, seen across multiple sessions) are automatically promoted to permanent pi-memory lessons on the next session start.
Tools
| Tool | Description |
|------|-------------|
| lesson_candidates | List pending lesson candidates by status |
| lesson_accept | Promote a candidate to a permanent lesson |
| lesson_reject | Reject a candidate permanently |
Commands
| Command | Description |
|---------|-------------|
| /lessons-review | Interactive review of pending candidates |
Storage
Candidates are stored in a SQLite database at ~/.pi/agent/lesson-extractor/candidates.db.
License
MIT
