## Why Long-running coding sessions drift. The user states a goal, the agent works on it, gets sidetracked, and loses sight of the original target. When context compaction occurs, the goal may be forgotten entirely. Pure skill-only designs force user interaction at every checkpoint, which breaks the "set and forget" intent. ## What Changes - Add a Pi skill `goal-driven-loop` that detects goal-setting phrases (Chinese, English, other languages), persists goal + acceptance criteria to `.agents/goal/GOAL.md`, and runs an instruction-based loop iterating until all criteria pass or genuine stagnation is detected - Add a Pi extension `goal-driven-loop` that automates trigger detection, state injection on every agent turn (resists context compaction), context tension detection via `ctx.getContextUsage()`, timed auto-default confirms (eliminates user-interaction hang-ups), and automatic delegation to comet for coarse-grained goals - Auto-generate verifiable acceptance criteria when not provided by the user - Per-iteration exponential backoff retry (10 retries, ~37min coverage) for transient failures - Dual-signal stagnation detection with auto-recovery injection before user notification - Deslop pass and clean exit on completion ## Capabilities ### New Capabilities - `goal-driven-loop`: Goal persistence and iteration loop with acceptance criteria verification, trigger/anti-trigger detection, state injection, and automatic retry/recovery ### Modified Capabilities ## Impact - New files: `.pi/skills/goal-driven-loop/` (skill instructions + error-handling reference), `.pi/extensions/goal-driven-loop/` (4 TypeScript modules + package.json) - Runtime: Extension subscribes to `input` and `before_agent_start` events - State: `.agents/goal/GOAL.md` created per-project during active goals, deleted on completion - Dependencies: Pi Extension API (`@earendil-works/pi-coding-agent`), node:fs, node:path - Integration: Delegates to `comet-open` for coarse-grained goals; no changes to comet itself