# `mix ptc.repl`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/mix/tasks/ptc.repl.ex#L1)

Starts an interactive REPL for testing PTC-Lisp expressions.

## Usage

    mix ptc.repl                      # Interactive REPL (default)
    mix ptc.repl -l user.clj          # Load user-code file, then interactive
    mix ptc.repl --prelude crm.clj    # Attach a deployment prelude
    mix ptc.repl --log-prelude        # Attach the built-in turn-log prelude
    mix ptc.repl --prelude crm.clj -e "(ns-publics 'crm)"
    mix ptc.repl --prelude crm.clj --show-prompt-inventory
    mix ptc.repl -e "(+ 1 2)"         # Eval and print result
    mix ptc.repl --upstreams-config upstreams.json -e "(tool/servers)"
    mix ptc.repl -e "(def x 1)" -e "(* x 2)"  # Chain evals (memory persists)
    mix ptc.repl script.clj           # Run script file
    mix ptc.repl -                    # Run from stdin

## Options

  * `-e, --eval` - Evaluate expression and print result (can be repeated)
  * `-l, --load` - Load file before entering interactive mode
  * `-p, --prelude` - Compile a deployment prelude file and attach it to every
    evaluation (protected namespaces, public exports, discovery). SEPARATE
    from `-l/--load`, which loads ordinary user code.
  * `--log-prelude` - Attach the built-in read-only `log/` introspection
    prelude to the REPL's default in-memory turn-log sink. Mutually exclusive
    with `--prelude` until general prelude composition is defined.
  * `--show-prompt-inventory` - Print the prelude's compact prompt inventory
    (the same rendering SubAgent execution injects) before evaluating.
  * `--upstreams-config` - Root upstream JSON config path
    (or `PTC_RUNNER_UPSTREAMS`)
  * `--max-tool-calls` - Per-evaluation `tool/call` cap
  * `--max-catalog-ops` - Per-evaluation discovery form cap
  * `--upstream-call-timeout-ms` - Per-upstream-call timeout
  * `--max-upstream-response-bytes` - Per-upstream response cap
  * `--catalog-mode` - Catalog exposure mode: `auto`, `inline`, or `lazy`
  * `--catalog-snapshot-mode` - Catalog snapshot mode: `live` or `frozen`
  * `-h, --help` - Print this help

## Features

- Evaluate PTC-Lisp expressions interactively
- Multi-line input: continues prompting until parens are balanced
- Turn history: `*1`, `*2`, `*3` reference last 3 results
- Memory persists between evaluations
- Optional upstream runtime for `(tool/call ...)`, `(tool/servers)`,
  `dir`, `doc`, `meta`, and `apropos`
- Exit with Ctrl+D

## Example Session

    ptc> (+ 1 2)
    3
    ptc> (* *1 10)
    30
    ptc> {:sum *1, :product *2}
    %{sum: 30, product: 30}

# `compile_prelude!`

```elixir
@spec compile_prelude!(Path.t()) :: PtcRunner.Lisp.Prelude.t()
```

Compiles a deployment prelude source file into a
`%PtcRunner.Lisp.Prelude{}` artifact — the SAME compiler, protected-namespace
tables, and export records SubAgent execution uses. Raises `Mix.Error` on a
missing file or a prelude compile/validation failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
