# pi-reader

Browse files pi has read during the session.

The extension tracks every file the assistant reads via the `read` tool and lets you
review them in a split-pane TUI viewer (file list on the left, content on the right),
wrapped in a border.

## Usage

Run the command in an interactive session:

```
/reader
```

- `up`/`down` (or `k`/`j`) — navigate the file list
- `PgUp`/`PgDn` — page through the list or content
- `left`/`right` (or `h`/`l`) — switch focus between the file list and content panes
- `Ctrl+←` / `Ctrl+→` — resize the split
- `Enter` — send the selected file back into the conversation
- `Esc` — close

Pass a path to also track a specific file before opening:

```
/reader path/to/file.ts
```

## How it works

- On `tool_call` for `read`, the file path is recorded in an in-memory map and appended
  to the session as a `reader-file` entry, so it survives `/reload` and session restore.
- On `session_start`, the tracked set is rebuilt from the session branch (both
  `reader-file` custom entries and historical `read` tool calls).

## Layout

```
pi-reader/
├── index.ts        # thin entry: re-exports src/index.ts (for auto-discovery)
├── package.json     # extension metadata + dev deps for typechecking
├── tsconfig.json
└── src/
    ├── index.ts     # event hooks + /reader command
    ├── state.ts     # tracked-file map + session rebuild
    └── viewer.ts    # BorderFrame + FileViewer split-pane component
```

## Development

Typecheck against the installed pi packages:

```bash
npm install --ignore-scripts
npm run typecheck
```
