# Work: Session Hygiene Extension ## Intent Link to: [docs/intent/2026-01-24-session-hygiene.md](../intent/2026-01-24-session-hygiene.md) ## Approach Link to: [docs/approach/2026-01-24-session-hygiene.md](../approach/2026-01-24-session-hygiene.md) ## Checklist ### Phase 1: Widget + git_commit Tool - [x] **W001**: Create extension directory structure - Verification: `ls ~/.pi/agent/extensions/session-hygiene/index.ts` - [x] **W002**: Implement git status helper - [x] **W003**: Implement footer widget showing dirty file count - Verification: `pi -e ~/.pi/agent/extensions/session-hygiene -p "test" 2>&1 | head -5` (no syntax errors) - [x] **W003**: Implement footer widget showing dirty file count - Verification: Start pi in a dirty repo, observe widget shows file count - [x] **W004**: Hook tool_result to update widget after bash/write/edit - Verification: In pi, write a file, observe widget count increases - [x] **W005**: Implement git_commit tool (stage files + commit) - Verification: `pi -p "Use git_commit to commit README.md with message 'test: verify tool'"` in test repo ### Phase 2: /commit Command - [ ] **W006**: Implement session context extraction (recent messages, file touchpoints) - Verification: `/commit` in pi shows context being gathered (log or notify) - [ ] **W007**: Implement /commit command that injects context and triggers LLM - Verification: `/commit` in dirty repo triggers LLM response with grouping proposal - [ ] **W008**: Verify full flow: /commit → LLM groups → git_commit calls → widget updates - Verification: End-to-end test in a repo with 5+ changed files across different paths ## Verification Evidence - (2026-01-24 23:xx) W001: `ls ~/.pi/agent/extensions/session-hygiene/index.ts` → exists - (2026-01-24 23:xx) W002: jiti load fails on missing module (expected) — syntax valid - (2026-01-24 23:xx) W003: Widget shows "4 files" in dim gray, disappears after commit - (2026-01-24 23:xx) W004: Widget updates after file writes - (2026-01-24 23:xx) W005: git_commit tool worked — committed docs, widget disappeared ## Notes - Extension location: `~/.pi/agent/extensions/session-hygiene/` - Will use `belowEditor` widget placement — need to verify it looks right - For /commit context injection, use `pi.sendUserMessage()` or `before_agent_start` message injection - Model for grouping: use whatever model is currently active (no separate API key needed)