# pi-compact-files

A zero-config Pi extension that shortens the file appendix in compaction summaries. It runs during compaction, before Pi saves and displays the summary, so successful compactions show the same compact appendix in the transcript, session file, and model context.

## Install

```bash
pi install npm:pi-compact-files
```

For local development:

```bash
npm install
npm test
npm run build
pi install "$PWD"
```

Restart Pi or run `/reload` after installing a local build. Pi `>=0.74.0` is required.

The package registers Pi's `session_before_compact` hook. It transforms the generated summary before Pi saves and displays it:

- preserves the narrative summary;
- removes recognized `pi-tmux-subagents` and `agent-work` job paths;
- deduplicates paths;
- reports retained and total file counts;
- shows representative modified files;
- keeps the generated appendix below 4,000 characters.

Before:

```markdown
<read-files>
/src/a.ts
/src/b.ts
... hundreds of paths ...
</read-files>
```

After:

```markdown
<files-summary>
Read: 52 files (302 total); omitted 250 subagent job outputs.
Read coverage: 12 directories.
Modified: 8 files (8 total); omitted 0 subagent job outputs.
Modified coverage: 2 directories.

Representative modified files:
- `/src/file-summary.ts`
- `/test/file-summary.test.ts`
</files-summary>
```

Ordinary messages are unchanged. The extension does not change Pi's compaction thresholds or token accounting. It rewrites only successful compaction summary text before persistence; native fallback may retain Pi's raw summary. The separate file-details bookkeeping remains available for diagnostics. The default `.pi-tmux-subagents` location and a configured `PI_TMUX_SUBAGENTS_DIR` are filtered without filesystem access.
