@tryinget/pi-session-compaction
Dedicated Pi package for custom session compaction summaries.
Package details
Install @tryinget/pi-session-compaction from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@tryinget/pi-session-compaction- Package
@tryinget/pi-session-compaction- Version
0.2.0- Published
- Jul 13, 2026
- Downloads
- 235/mo · 235/wk
- Author
- tryinget
- License
- SEE LICENSE IN LICENSE
- Types
- extension
- Size
- 209.9 KB
- Dependencies
- 2 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/session-compaction.js"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
summary: "@tryinget/pi-session-compaction package overview." read_when:
- "Orienting to this package or directory before changing its behavior."
@tryinget/pi-session-compaction
Dedicated Pi package for custom session compaction summaries.
Live posture
This package is now the local live owner for custom session_before_compact summaries after an explicit cutover preflight found no other installed compaction override packages.
- exposes
package.json#pi.extensionsthroughextensions/session-compaction.js - registers input tracking for preserving slash-command prompts
- registers exactly one
session_before_compacthandler through the fail-closed registration guard - exposes
/compact-focus, a guided operator menu that calls the same compaction path with selected custom instructions - exposes
/compact-handoffand thesession_compaction_handofftool for owner-owned, operator-pasteable fresh-session handoff prompts before compaction/reload; the tool accepts structured discovery/promotion-status records for insights that still need owner-surface promotion - does not expose prompt bundles or
package.json#pi.prompts - falls back to stock compaction when the custom summarizer cannot be resolved, except explicit malformed/preset-directed paths that intentionally cancel rather than silently producing the wrong preset summary
After local install, reload Pi with /reload before expecting the current session process to use the new hook.
Ownership
This package is the intended single owner of custom session_before_compact summaries in the pi-extensions monorepo.
pi-session-compactionowns custom summary content and shape.pi-autonomous-session-controlremains the runtime/subagent/rewind owner and should only observesession_compactfor rewind aliasing.- Do not install/enable multiple custom compaction overrides at once.
Current slice
This package currently implements the compaction-facing foundations and a tested live handler module:
- current-session model fallback
- named preset resolution (
exact, case-insensitive, prefix, normalized substring) - prompt-template-model-aligned model fallback semantics imported from
@tryinget/pi-model-selection: exactmodelId, exactprovider/modelId, comma-separated fallback lists, current-model preservation, and provider-priority ordering for ambiguous bare IDs - compatibility with both Pi host auth APIs through
@tryinget/pi-model-selection:modelRegistry.getApiKeyAndHeaders(model)modelRegistry.getApiKey(model)
- preservation of model-level
headers - normalized thinking levels
- files-touched collection ported from dot314 grounded-compaction, including read/write/edit/move/delete tracking, no-op edit filtering, move redirects, repo-relative display paths, and manifest rendering
- user prompt / command preservation ported from legacy
pi-user-prompt-compaction, including expanded skill-block recovery, timestamp-matched slash command recovery, previous-summary prompt-section recovery, and/compact <customInstructions>preservation extensions/session-compaction/handler.jsassembly forsession_before_compact, including compact-instruction parsing, config loading, stock-boundary span derivation, summary prompt assembly, final files-touched manifest append, essential-prompt append/deduplication, safe stock fallback, and abort cancellationextensions/session-compaction/registration.jsguard for hook activation, including default-disabled registration, explicit handler-test confirmation, explicit no-double-compaction preflight, existing-handler zero-count proof, duplicate package-registration blocking, and optional input tracking for slash-command preservation without slash-command registration- live
extensions/session-compaction.jsentrypoint, which enables input tracking, guardedsession_before_compactregistration, and/compact-focuswithout adding prompt bundles - non-live
extensions/session-compaction/branch-summary.jshelpers for optionalsession_before_treeaugmentation, including prompt-contract loading, files-touched instructions, focus text preservation, and safe undefined-on-failure behavior extensions/session-compaction/handoff-prompt.jsfor the canonical fresh-session prompt affordance, including linked discovery records with valuable-discovery, source, promotion-status, owner-surface, metric, falsifier, and non-authorization fields; ASC/self may route or provide mirror-only cues, but this package owns compaction/handoff prompt shape- clear failure messages for missing models, ambiguous matches, unsupported reasoning, and incompatible registries
The live hook should remain the only custom compaction override. If another compaction owner is installed later, remove or disable one before reloading Pi.
Template baseline
This package was reconciled through ../pi-extensions-template in simple-package mode, then intentionally adapted for the current compaction foundation. It keeps template lineage and baseline files such as .copier-answers.yml, biome.jsonc, policy/engineering-lane.json, and docs/engineering.local.md. It exposes package.json#pi.extensions for the live hook and /compact-focus, but still deliberately omits package.json#pi.prompts.
Target summary shape
## Brief
- Current objective
- Current state
- Immediate next action
## Constraints & preferences
- User-stated constraints and preferences
## Key decisions & rejected paths
- Decisions
- Failed/rejected approaches worth not repeating
## Status
- Done
- In progress
- Unverified
- Blocked
## Valuable discoveries and promotion status
- Strategic session-only insights that must survive reload
- Source and owner surface for promotion
- Promoted, deferred, or still needs exact promotion action
- Metrics, falsifiers, and non-authorizations
## Open issues and uncertainties
- Facts vs inferences
## Immediate next steps
1. Concrete next action
2. Validation
3. Follow-up
## Mandatory reading
- exact/file/path.ts
- docs/exact-doc.md
## Essential user prompts / commands + arguments used
1. original user request
2. /skill:frontend-design ...
3. /template:review ...
---
## Files touched (cumulative)
R=read, W=write, E=edit, M=move/rename, D=delete
```text
RE src/foo.ts
W src/bar.ts
```
Design inputs
The full implementation should port and reconcile these sources:
- grounded compaction foundation from
softwareco/contrib/dot314/extensions/grounded-compaction/ - files-touched core from
softwareco/contrib/dot314/extensions/_shared/files-touched-core.ts - user prompt/command preservation from legacy
~/programming/pi-extensions/pi-user-prompt-compaction - installed prompt frontmatter model semantics from
npm:pi-prompt-template-model(/home/tryinget/.npm-global/lib/node_modules/pi-prompt-template-model/model-selection.tsandprompt-loader.ts) - observed prompt-template model lifecycle ideas from
packages/pi-prompt-template-accelerator/src/ptxRuntimeRegistry.js
The live /commit prompt now gets its model behavior from packages/pi-prompt-template-execution, not from Pi core prompt-template loading and not from pi-prompt-template-accelerator. The shared resolver semantics live in packages/pi-model-selection (@tryinget/pi-model-selection): exact specs, comma fallback, current-model preservation, auth-aware candidate selection, and provider priority openai-codex -> anthropic -> github-copilot -> openrouter. This package keeps only compaction-specific preset, thinking, and summarizer resolution logic.
Validation
cd packages/pi-session-compaction
npm run test
npm run check
Next implementation steps
- Reload Pi after local install and observe one real compaction event before treating the cutover as fully proven in the active operator session.
- Keep branch-tree summary augmentation non-live unless a separate plan explicitly enables
session_before_treebehavior. - Preserve the no-double-compaction invariant before any future package install/reload.