A small collection of Pi extensions for keeping long sessions focused without constantly stopping to compact.
The core workflow is /diligent-context here: when you reach a useful milestone in a dev session, run it to mark the current point as the context boundary. From then on, older tool-call chatter before that boundary is hidden from the LLM at runtime, while the human conversation and recent work stay visible.
Nothing is deleted or rewritten. The transcript remains intact; diligent-context only shapes what Pi sends to the model.
In practice, this lets you turn a session that is nearing the context limit back into a manageable working set, without doing a lossy compaction or interrupting your flow.
This is still a pruning boundary, not a hard fit guarantee. If the remaining human conversation and recent work are themselves too large for the selected model, you may still need to move the boundary later, run compaction, or switch to a larger-context model.
The companion extensions build on that boundary:
diligent-compactmakes/compactrespect the same visible context boundary if you do compact later.diligent-contemplatecreates a richer hand-over summary before resetting the boundary, so you can preserve the important decisions and state from the milestone before hiding more tool-heavy history.
Install the extensions together in dependency order:
- diligent-context: owns the pruning boundary, hides stale tool chatter from the live model payload, preserves human conversation, and persists boundary-surviving checkpoints.
- diligent-compact: keeps
/compactand explicit/diligent-compactaligned with the same diligent-visible universe the model sees, carrying active checkpoints forward as structured summary input. - diligent-contemplate: explicitly generates semantic contemplation checkpoints, stores them through
diligent-context, and re-anchors after the represented real visible payload.
Dependency notes:
diligent-compactdepends on shared helpers fromdiligent-context/core.ts.diligent-contemplatedepends on bothdiligent-contextanddiligent-compact/shared.ts.- If you only want pruning and visibility-aware compaction, install
diligent-contextanddiligent-compacttogether. - If you want contemplation checkpoints, install all three folders.
Distribution is intentionally copy-based and lightweight for now. There is no package wrapper, installer script, release automation, or CI-backed publish flow in this repo.
Copy the extension folders into one of Pi's extension directories:
~/.pi/agent/extensions/for user-level use, or<your-project>/.pi/extensions/for project-local use.
User-level install example:
mkdir -p ~/.pi/agent/extensions
cp -R extensions/diligent-context ~/.pi/agent/extensions/
cp -R extensions/diligent-compact ~/.pi/agent/extensions/
cp -R extensions/diligent-contemplate ~/.pi/agent/extensions/Project-local install example:
mkdir -p <your-project>/.pi/extensions
cp -R extensions/diligent-context <your-project>/.pi/extensions/
cp -R extensions/diligent-compact <your-project>/.pi/extensions/
cp -R extensions/diligent-contemplate <your-project>/.pi/extensions/Current Pi packages use the @earendil-works/* scope. Some extension imports still use legacy @mariozechner/* names because the current Pi extension loader provides those compatibility aliases.
To update an installed copy, copy the extension folders from this repo again.
Local model choices should live in config.local.json inside the installed diligent-compact directory. That file is git-ignored here and is not shipped by the repo, so normal copy updates do not overwrite it unless you delete the installed extension directory yourself.
Note that cp -R updates and adds files but may leave stale files behind if a future release removes or renames files. If you want a pruned mirror, use a delete-aware copy such as rsync --delete while excluding local state like diligent-compact/config.local.json and diligent-compact/compactions/.
If you remove installed folders before copying, back up and restore:
~/.pi/agent/extensions/diligent-compact/config.local.json, or<your-project>/.pi/extensions/diligent-compact/config.local.json.
/diligent-context: open the control menu./diligent-context here: set the boundary after the current live payload tail, or store a pending intent if no live payload exists yet./diligent-context pick: pick a boundary from the current live payload./diligent-context off: disable diligent-context and clear active checkpoints.
/compact: use Pi's normal compaction command; whendiligent-contextis active, this is routed through a visibility-aware compatibility path./diligent-compact [instructions]: run the explicit opinionated compaction path using the configured model/prompt/thinking stack./diligent-compact --force-native [instructions]: one-shot native override that intentionally bypasses diligent visibility guarantees.
/diligent-contemplate [custom prompt]: generate a contemplation checkpoint from the current diligent-visible live payload.
diligent-compact owns the shared opinionated model configuration used by both explicit /diligent-compact and /diligent-contemplate.
Configuration is layered:
- in-code defaults,
- shipped
extensions/diligent-compact/config.json, - ignored local override
config.local.jsonin the installeddiligent-compactdirectory.
To customize a user-level install:
cp ~/.pi/agent/extensions/diligent-compact/config.local.example.json \
~/.pi/agent/extensions/diligent-compact/config.local.jsonTo customize a project-local install:
cp <your-project>/.pi/extensions/diligent-compact/config.local.example.json \
<your-project>/.pi/extensions/diligent-compact/config.local.jsonThe shipped candidate order is:
anthropic/claude-opus-4-7withthinkingLevel: "xhigh"openai-codex/gpt-5.5withthinkingLevel: "xhigh"openai-codex/gpt-5.4withthinkingLevel: "xhigh"anthropic/claude-sonnet-4-6withthinkingLevel: "high"- the current session model as the final runtime fallback
At runtime, configured candidates are checked against Pi's model registry and auth. Candidates are skipped if they are not registered, have no usable API key/request headers, or return an auth error. If all configured candidates are skipped, opinionated paths fall back to the current session model and emit one concise warning. Compatibility /compact intentionally follows Pi's current-model behavior.
Useful local override patterns:
- omit a field to inherit it from the prior layer;
- set
compactionModels: []to intentionally use current-session fallback only; - set
debugCompactions: trueto write additional debug artifacts.
Invalid local config warns and falls back instead of crashing extension import.
diligent-contextowns the pruning boundary, persisted checkpoints, restoration, and checkpoint projection rules.- Persisted diligent state is authoritative; runtime snapshots are caches only.
- Synthetic checkpoint messages are projected only in the
contextreturn path and never pollute realrawMessages,filteredMessages, orfilteredToRawIndicessnapshots. diligent-compactperforms visibility-aware compaction over the same live visible universe the model sees.- Active checkpoints are supplied to compaction as structured carry-forward input, not ordinary chat history.
diligent-contemplateproduces semantic checkpoints without relying on a Pi-core assistant-message persistence API.- This polish pass does not change the persisted diligent state schema.
From the repo root:
bun run validate:localThat script currently runs the Bun test suite:
bun test testsValidation is local-only in this repo. There is no CI workflow or package-publishing validation surface yet.
When diligent-context is active, /compact fails closed if the current visible live payload cannot be safely mapped back to session entries. This avoids summarizing hidden or speculative history. If you intentionally want to bypass visibility guarantees once, run:
/diligent-compact --force-native [instructions]
This means every configured candidate was skipped because it was unavailable or lacked usable auth. Check Pi model auth and your installed config.local.json.
The command intentionally fails without writing state when there is no current diligent-visible payload, the boundary is restoring or lost, nothing new happened since the active contemplation checkpoint, model auth is unavailable, the prompt is too large, the model output is empty, or the live session changes mid-generation.
Alignment diagnostics are written to:
~/.pi/agent/extensions/diligent-compact/compactions/latest-alignment-divergence.json
If debugCompactions is enabled, additional timestamped artifacts and debug logs are written under:
~/.pi/agent/extensions/diligent-compact/compactions/
Those artifacts are local/generated state and should not be committed.
When a real Pi user-level install is available, copy all installed folders and smoke the critical paths:
/diligent-compactwith configured candidates unavailable warns before current-model fallback./diligent-compact --force-nativewarns that visibility guarantees are bypassed./diligent-contemplateemits a checkpoint artifact and re-anchors after represented real visible payload.- A successful compaction after active checkpoints clears them.
Record whether this smoke was run in CHANGELOG.md or implementation notes before calling a polish pass complete.
The extensions are stable enough to use, but the public distribution surface is still intentionally simple: copy folders, preserve local config, run local validation, and avoid treating downstream copies as canonical.