Hi, I recently started this small project for my own Scala teaching efforts and would like to share it with the community.
Motivation: When using the Scala REPL to demo something in class, I can’t always remember the exact import required or correct API usage. To address those moments, I thought it would be helpful to integrate AI code generation directly into the REPL.
scrai (pronounced “scry”) is a lightweight AI input widget for the native Scala 3 REPL (standalone CLI) and sbt console plugin (sbt-console-ai). It lets you type an AI prompt as a // inline comment, press Ctrl-G, review the generated Scala, then press Enter to evaluate it. Generation never submits the code automatically, so you’re in control of what runs.
scala> val words = List("pear", "apple", "plum", "apricot")
scala> // group words by their first letter ───[ Type prompt & press Ctrl-G ]───►
scala> words.groupBy(_.head) ◀───[ Generated code inserted inline ]
Source, instructions, standalone release, and artifacts are available here:
Requirements and build matrix: JDK 17 or newer, a real interactive terminal, and a Groq API key. Supported combinations: sbt 1.13.x and sbt 2.0.x, each with Scala 3.3.x through 3.10.x projects (scrai drives the compiler’s REPL internals and ships one runtime variant per Scala minor line; the dev build itself uses sbt 1.13.0).
Feedback and contributions are welcome!
Acknowledgment: The project was heavily inspired by the elegant, distraction-free terminal workflow of the fish-ai shell extension.