4 5 
7 9 Persistent standing-goal loop for Pi sessions.
11 -Loaded through the root pi-ext package. See [../../README.md](../../README.md).
13 +Loaded through the root pi-ext package.
14 +See [../../README.md](../../README.md).
15 -Subcommands autocomplete. `/goal remove` autocompletes criterion numbers.
18 +Subcommands autocomplete.
19 +`/goal remove` autocompletes criterion numbers.
40 44 update_goal({ status: "complete" | "blocked", reason: string })
43 -Marks the active goal complete or blocked. Hidden until a continue verdict increments `turnsUsed`, then hidden again when the goal is complete, blocked, paused, cleared, or resumed into a fresh 0-turn state. If invoked while stale, it errors when no active goal exists, the goal has not been judged, or the goal belongs to another session.
47 +Marks the active goal complete or blocked.
48 +Hidden until a continue verdict increments `turnsUsed`, then hidden again when
49 +the goal is complete, blocked, paused, cleared, or resumed into a fresh 0-turn
51 +If invoked while stale, it errors when no active goal exists, the goal has not
52 +been judged, or the goal belongs to another session.
57 -- `maxTurns`: turn budget for a new goal. Default `20`, clamped to `1..10000`.
58 -- `judgeModel`: optional Pi model ref, `provider/model`. When unset, the current session model is used.
59 -- `tailBytes`: bytes read from the latest assistant response for judgment. Default `4096`, clamped to `512..65536`.
67 + turn budget for a new goal.
68 + Default `20`, clamped to `1..10000`.
70 + optional Pi model ref, `provider/model`.
71 + When unset, the current session model is used.
73 + bytes read from the latest assistant response for judgment.
74 + Default `4096`, clamped to `512..65536`.
73 88 - `/goal` and `/goal status` print current goal status.
74 -- `/goal <objective>` creates an active goal with empty criteria, current session ownership, and the configured turn budget. It sends a kickoff prompt immediately.
75 -- A raw prompt containing `standing goal` plus an `<objective>...</objective>` block is adopted as an active goal when no goal exists.
76 -- New goals require an idle agent. Subcommands can run while the agent is busy.
77 -- Goal state is stored as append-only custom `goal-state` entries. Replay scans backward; newest valid state or clear tombstone wins.
78 -- `before_agent_start` injects the active goal and criteria into the system prompt for the owning session.
79 -- After each owned active goal turn, the extension writes a `goal-judge` start entry, shows `goal judging N/M` in persistent UI, then asks a judge model for strict JSON: `done`, `blocked`, `reason`.
80 -- The judge sees the objective, criteria, and tail of the latest assistant response.
81 -- Judge completion writes a `goal-judge` verdict entry and updates the goal widget/footer with the latest verdict reason.
82 -- Continue verdicts stay quiet except for persistent UI. Complete, blocked, paused, and judge-failed verdicts notify.
83 -- Done verdict marks the goal complete and clears persistent status/widget/footer. Blocked verdict marks it blocked and keeps persistent UI.
89 +- `/goal <objective>` creates an active goal with empty criteria, current
90 + session ownership, and the configured turn budget.
91 + It sends a kickoff prompt immediately.
92 +- A raw prompt containing `standing goal` plus an `<objective>...</objective>`
93 + block is adopted as an active goal when no goal exists.
94 +- New goals require an idle agent.
95 + Subcommands can run while the agent is busy.
96 +- Goal state is stored as append-only custom `goal-state` entries.
97 + Replay scans backward; newest valid state or clear tombstone wins.
98 +- `before_agent_start` injects the active goal and criteria into the system
99 + prompt for the owning session.
100 +- After each owned active goal turn, the extension writes a `goal-judge` start
101 + entry, shows `goal judging N/M` in persistent UI, then asks a judge model for
103 + `done`, `blocked`, `reason`.
104 +- The judge sees the objective, criteria, and tail of the latest assistant
106 +- Judge completion writes a `goal-judge` verdict entry and updates the goal
107 + widget/footer with the latest verdict reason.
108 +- Continue verdicts stay quiet except for persistent UI.
109 + Complete, blocked, paused, and judge-failed verdicts notify.
110 +- Done verdict marks the goal complete and clears persistent
111 + status/widget/footer.
112 + Blocked verdict marks it blocked and keeps persistent UI.
84 113 - Incomplete verdict increments `turnsUsed`; exhausted budget pauses the goal.
85 -- If still active, continuation is sent when the session becomes idle. Retry window: 20 attempts, 250 ms apart after the immediate attempt.
86 -- `update_goal` is hidden until the first continue verdict increments `turnsUsed`, then hidden again for terminal or paused goals.
114 +- If still active, continuation is sent when the session becomes idle.
116 + 20 attempts, 250 ms apart after the immediate attempt.
117 +- `update_goal` is hidden until the first continue verdict increments
118 + `turnsUsed`, then hidden again for terminal or paused goals.
87 119 - `/goal pause` only pauses active owned goals.
88 -- `/goal resume` rebinds a goal to the current session, sets it active, resets `turnsUsed`, and schedules continuation.
89 -- `/goal complete [reason]` is a user override. Default reason: `marked complete by user`.
120 +- `/goal resume` rebinds a goal to the current session, sets it active, resets
121 + `turnsUsed`, and schedules continuation.
122 +- `/goal complete [reason]` is a user override.
124 + `marked complete by user`.
90 125 - `/goal clear` writes a clear tombstone and removes status.
91 -- `/goal add`, `/goal remove`, and `/goal clear-criteria` edit criteria on the current owned goal.
92 -- `/goal criteria` lists criteria. Empty criteria print `No goal criteria.`
93 -- UI status key: `goal` for active, paused, judging, and blocked goals when the shared `footer` extension is absent. Complete/cleared goals clear status and notify instead.
94 -- UI widget key: `goal`. Active, judging, paused, and blocked goals show an above-editor widget with phase, turn progress, objective, and last judge reason.
95 -- Shared footer integration: emits `footer:segment` id `goal` when `extensions/footer` is loaded.
96 -- Goals owned by another session show `owned by another session`; mutating commands require `/goal resume` first.
97 -- `PI_GOAL_PROBE=1` adds `/goal-probe` and writes custom `goal-probe` entries for continuation scheduling checks.
126 +- `/goal add`, `/goal remove`, and `/goal clear-criteria` edit criteria on the
127 + current owned goal.
128 +- `/goal criteria` lists criteria.
129 + Empty criteria print `No goal criteria.`
131 + `goal` for active, paused, judging, and blocked goals when the shared `footer`
132 + extension is absent.
133 + Complete/cleared goals clear status and notify instead.
136 + Active, judging, paused, and blocked goals show an above-editor widget with
137 + phase, turn progress, objective, and last judge reason.
138 +- Shared footer integration:
139 + emits `footer:segment` id `goal` when `extensions/footer` is loaded.
140 +- Goals owned by another session show `owned by another session`; mutating
141 + commands require `/goal resume` first.
142 +- `PI_GOAL_PROBE=1` adds `/goal-probe` and writes custom `goal-probe` entries
143 + for continuation scheduling checks.