refactoring after #830

* introduce `IRepl`
* move `IReplEngine` to own file
* add guards
* remove redundant code
* fix code formatting
* add `readonly`

also fixes #434