# Changelog

## [0.6.1] - 2026-11-02

### Fixed
- Draw recaps on OpenCode and OpenCode Go models. OpenCode rejects any request that does not name its session, and the recap request did not, so every recap on those models failed with `400 MissingSessionID`. The recap now sends the session ID, as Pi's own requests do ([#133](https://github.com/tmustier/pi-extensions/issues/133)).

Thanks to @mtford90 for the report and diagnosis.

## [0.6.0] - 2026-10-28

### Added
- Save each recap in the session as a `session-recap` custom entry holding the recap text and the model that drafted it. When a session is reopened and nothing that would change the recap has landed since, the saved recap is shown at once with no model call; otherwise a new one is drafted and saved. Restoring many terminal tabs no longer costs a model call per tab when nothing has changed. Recaps drawn while the agent is running are shown but not saved. Saved recaps are never sent to the model and do not appear in the transcript.

- Preserve the session file's access and modification times when saving a recap, so an away recap does not change which session `pi -c` reopens.

Thanks to @ferologics for the idea.

## [0.5.5] - 2026-10-28

### Fixed
- Draw a recap in a session larger than the recap model's context window. pi-ai caps `max_tokens` to what fits in the window, and estimates the request from the usage of its last assistant message. The recap copies those messages from the session, so that usage described the whole session rather than the recap's own few thousand tokens. Past the recap model's window, the recap was capped at 1 token and nothing was shown. The recap now sizes the request from its own messages ([#125](https://github.com/tmustier/pi-extensions/issues/125), [#126](https://github.com/tmustier/pi-extensions/pull/126)).
- Send the recap to the endpoint that comes with the login. Some logins, such as a GitHub Copilot enterprise account, route requests to their own endpoint. The recap used the model's standard endpoint instead, so those recaps failed with a 401 while Pi's own requests worked ([#118](https://github.com/tmustier/pi-extensions/issues/118), [#119](https://github.com/tmustier/pi-extensions/pull/119)).

Thanks to @ferologics for the report, diagnosis, regression test, and fix for the context window, and to @gambtho for the report and fix for the endpoint.

## [0.5.4] - 2026-10-27

### Changed
- Draft recaps with Claude Haiku 5.5 in Anthropic sessions and GPT-6 Luna in GPT sessions, replacing Claude Haiku 4.5 and GPT-5.6 Luna. When the provider doesn't offer the newer model, the recap uses the active model.

### Fixed
- Stop sending Pi's system prompt and tools with the recap. Pi 1.x saves them in the session as `system` messages, and the recap copied them along with the conversation, so each recap carried Pi's full prompt (about 28,000 characters) and tool definitions. On an Anthropic subscription, that request is billed as third-party usage, so recaps failed with a 400 once the account had no extra usage left, whichever model drafted them. The recap now sends only the conversation ([#122](https://github.com/tmustier/pi-extensions/issues/122), [#123](https://github.com/tmustier/pi-extensions/pull/123)).

Thanks to @ferologics for the report ([#122](https://github.com/tmustier/pi-extensions/issues/122)).

## [0.5.3] - 2026-10-26

### Fixed
- Draw a recap when a session is reopened from the command line (`pi -c`, `pi -r`, `pi --session <file>`, or a terminal restoring its sessions). Pi reports these as a `startup` session start, and only an in-process `/resume` as `resume`, so the recap only ever fired on `/resume` and `/fork`. A fresh session still draws no recap, and neither does reopening with a prompt, since the agent starts work straight away.

Thanks to @ferologics for the report and diagnosis.

## [0.5.2] - 2026-10-26

### Fixed
- Draw a recap only for a cleanly stopped response. `complete`/`completeSimple` resolve rather than throw when a stream fails, is aborted, or stops at the token cap, and the message they return holds only the text that arrived before the cut. Rendering that fragment produced recaps of a single dangling word. A stream failure is now reported with the provider's error message instead of passing silently.
- Report a recap failure through `ctx.ui.notify` instead of `console.error`. Pi installs no console interception, so an extension writing there put a multi-line stack straight onto the terminal in the middle of a frame, overwriting the status bar it landed on.

Thanks to @CrazyCoder for the report, regression tests, and fix ([#105](https://github.com/tmustier/pi-extensions/issues/105), [#106](https://github.com/tmustier/pi-extensions/pull/106)).

## [0.5.1] - 2026-09-22

### Changed
- Build recaps from Pi 0.87's projected session context so context edits, omissions, and replacements are reflected in both recent activity and initial task framing.
- Wait for final agent settlement before generating an away recap, including after retries, compaction, and queued continuations.

## [0.5.0] - 2026-08-14

### Changed
- Show recaps as temporary content at the end of the scrollable transcript in fullscreen mode, rather than as a fixed widget above the editor. Regular mode keeps the existing widget placement.

### Fixed
- Explicitly disable reasoning for Codex recap models instead of inheriting the server-side default effort.

## [0.4.1] - 2026-08-06

### Changed
- Simplified the extension implementation and documentation without changing recap behaviour.

## [0.4.0] - 2026-08-06

### Changed
- Replace the flattened 12,000-character transcript with a 30-message native conversation window, the initial request, and the latest compaction or branch summary. Long initial requests and tool results retain their beginning and end.
- Use Claude Code's recap instruction verbatim, removing the extra file/error rules and the 600-character output truncation.

## [0.3.0] - 2026-08-06

### Fixed
- Let Pi wrap recap text at the terminal width instead of inserting breaks at 100 characters.

### Changed
- Prefer Claude Haiku 4.5 for Anthropic sessions, or GPT-5.6 Luna when the active model is GPT and its provider offers Luna. Fall back to the active model; `--recap-model` still takes precedence.

## [0.2.2] - 2026-07-21

### Fixed
- Skip recap generation silently when the active model uses a custom API handler that is registered only in Pi's runtime and cannot be resolved by pi-ai's standalone compatibility layer. Users can still select a supported recap model with `--recap-model`.
- Publish the metadata-only branch deduplication fix listed under 0.2.1. Version 0.2.2 is the first npm release since 0.2.0.

Thanks to @timvdhoorn for reporting and fixing the custom-provider failure ([#81](https://github.com/tmustier/pi-extensions/pull/81)).

## [0.2.1] - 2026-07-05

### Fixed
- Avoid redundant automatic recap generation when the recap prompt has not changed, even if Pi has advanced the session leaf with metadata-only entries (for example session info, model/thinking changes, labels, or leaf markers). Dedupe now uses a fingerprint of the capped recap transcript rather than the raw branch leaf id.

## [0.2.0] - 2026-07-04

Away-recap redesign informed by Claude Code's away-summary implementation.

### Fixed
- **Restore recap generation on pi 0.80.x**: import `completeSimple`/`getModel` from `@earendil-works/pi-ai/compat` — the root export dropped them, which silently broke v0.1.3 at runtime.
- Stop requiring `auth.apiKey`: env/ambient-auth providers (e.g. Bedrock) resolve with `ok: true` and no key. Only bail when auth resolution fails, and pass `env` through to the completion call.

### Changed
- **Triggers**: recaps are no longer drafted on every focus-out. A recap is generated after `--recap-away-seconds` (default 90) of continuous blur, or when a turn ends while the terminal is blurred (3s debounce). Quick alt-tabs no longer fire (and then abort) model calls.
- **Idle fallback is now conditional**: armed only while the terminal has not demonstrated focus-reporting support; the first real focus event disarms it for the session. Default raised 45s → 120s.
- **Prompt**: adopted Claude Code's orientation philosophy — 1-3 short sentences, high-level task first, concrete next step, explicitly skipping status reports and commit recaps. v0.1 asked for a status report of the last turn, which duplicated what was already in scrollback.
- **Context**: two-tier transcript — recent detail since the last user message (as before), plus cheap task framing: up to 4 earlier user prompts (trimmed to 300 chars) and the most recent compaction/branch summary. Same 12k-char overall cap, so worst-case cost is unchanged.
- **Widget**: recap can now span 1-3 sentences, soft-wrapped to at most 4 dim lines.
- Recaps generated while away are shown immediately (parked above the editor for your return) instead of being held for reveal on focus-in.
- An in-flight draft is no longer cancelled on refocus — it lands moments after you return, which is when it helps.
- Resume/fork recaps use the same two-tier builder instead of feeding the entire branch.

### Added
- `--recap-away-seconds <n>` (default 90) — continuous blur before an away recap.

### Removed
- `--recap-focus-min-seconds` — no drafts on focus-out means no quick-glance suppression to tune, and the `pendingRecap` park/reveal/cancel machinery is gone with it.

## [0.1.3] - 2026-05-12

### Fixed
- Defer focus-triggered recaps while the agent is still active, matching Claude Code's away-summary pending behavior and avoiding duplicate/stale recaps during slow tool calls.
- Cancel stale in-flight recap drafts when a new turn starts.
- Skip `/resume` and `/fork` recap generation in headless/non-UI sessions.
- Read registered flag values using bare flag names (for example `recap-idle-seconds`, not `--recap-idle-seconds`) so automatic trigger configuration actually takes effect.
- Invoke recap generation with no reasoning, no prompt-cache retention, and `maxTokens: 256`.

### Added
- Add `--recap-during-active` to opt back into focus-triggered recaps while an agent turn is still running.

## [0.1.2] - 2026-05-07

### Changed
- Declare the `@earendil-works` Pi peer and development dependencies used by runtime imports.
- Update Pi extension imports to the new `@earendil-works` namespace.

## v0.1.0

- Initial release.
- Two triggers: DECSET `?1004` focus reporting + idle fallback on `turn_end`.
- Auto-recap on `/resume` and `/fork`.
- `/recap` command for manual generation.
- Defaults to the user's active model with `reasoning: "minimal"` when supported, for zero-auth-surprise behaviour across built-in and custom providers.
- Flags: `--recap-idle-seconds`, `--recap-focus-min-seconds`, `--recap-disable-focus`, `--recap-disable`, `--recap-model`.
- Draft stamping by branch-leaf id to avoid regenerating on focus-out/in churn without new session activity.
- Idle fallback armed on `turn_end` rather than `agent_end` so errored/aborted turns still get a recap.
- Robust focus-event parser that advances through its buffer so completed sequences never fire twice across chunk boundaries.
- Per-call `AbortController` ownership so late-completing aborted requests can't clear state for a newer in-flight request.
- Quick refocus (< `--recap-focus-min-seconds`) now also cancels any in-flight focus draft, preventing a slow model response from bypassing the suppression.
