# Pi integration

This package registers a custom `repling` provider for Pi.

## What to use

The extension registers:

- provider: `repling`
- models such as `repling-gpt-5.3-codex`, `repling-gpt-5.2-codex`,
  and `repling-gpt-5.1-codex`
- compatibility model: `bridge`

## Quick start from Pi

Install the published package:

```bash
pi install npm:@pfeodrippe/repling-pi
```

After that, start Pi with:

```bash
pi --provider repling --model repling-gpt-5.3-codex
```

You can also start `pi` normally and choose a `repling/...` model from `/model`
or Ctrl+L. The selected Pi model is passed through to Repling.

By default the extension uses Pi's own `openai-codex` auth. If you have not
logged in yet, start `pi`, run `/login` inside the TUI, and choose the
ChatGPT/Codex auth option. The extension resolves that token from Pi and passes
it to the Repling bridge through child-process environment variables. You do
not need a separate bridge API key for the default path.

## Useful flags

- `--repling-bridge-provider openai-codex` (default, uses Pi `/login` auth)
- `--repling-bridge-provider openai-responses` (OpenAI Platform API)
- `--repling-bridge-provider codex-cli` (raw text/debug path only)
- `--repling-bridge-provider pi-openai-codex` (raw text/debug path only)
- `--repling-bridge-model gpt-5.3-codex`
- `--repling-bridge-path /absolute/path/to/repling-pi-bridge.mjs`
- `--repling-project-dir /absolute/path`
- `--repling-sessions-root /absolute/path`
- `--repling-system-prompt "You are terse."`
- `--repling-compaction-tool project.compaction/compact`
- `--repling-load-project-tools`
- `--repling-repl-deps` (enable Clojure 1.12 runtime dependency loading)
- `--repling-auto-compaction`
- `--repling-timeout-ms 60000`
- `--repling-max-retries 1`
- `--repling-retry-delay-ms 1000`
- `--repling-endpoint https://...`
- `--repling-api-key ...`
- `--repling-api-key-env MY_KEY_ENV`

## Useful TUI commands

- `/repling-state`
- `/repling-model <provider> <model>`
- `/repling-repl-deps on`
- `/repling-repl-deps off`
- `/repling-reset`

`/repling-repl-deps on|off` is persisted per project cwd in Pi's agent config
directory and mirrored into the current Pi session, so later Pi runs in the same
folder reuse the setting. The startup flag `--repling-repl-deps` still enables
it for that process even if no persisted project setting exists yet.

The extension defaults to a short retry profile (`--repling-max-retries 1`,
`--repling-retry-delay-ms 1000`) so interactive Pi sessions fail fast instead of
appearing hung behind long provider retry loops.

## Session behavior

The extension does not restore old Repling bridge sessions automatically and
does not inject prior Pi transcript messages into new Repling prompts. It only
uses Pi session files for the current project to populate editor prompt history,
so previous user messages are selectable with editor history navigation without
becoming model context.

## Slash commands

- `/repling-help`
- `/repling-state`
- `/repling-reset`
- `/repling-model <provider> <model>`
- `/repling-repl-deps on`
- `/repling-repl-deps off`

Normally you should use Pi's `/model` picker for model selection. `/repling-model`
remains available for overriding the lower-level bridge provider manually.
