npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@prism-lang/repl

v1.2.3

Published

Interactive REPL for Prism language

Readme

@prism-lang/repl

Interactive REPL (Read-Eval-Print Loop) for the Prism programming language. Provides a command-line interface for experimenting with Prism code interactively.

📚 Full Documentation | 🚀 Getting Started | 🖥️ CLI Usage

Installation

The REPL is typically installed as part of the CLI package:

npm install -g @prism-lang/cli

Usage

Start the REPL by running:

prism
# or
prism repl

Features

  • Interactive Evaluation: Execute Prism code line by line
  • Multi-line Input: Support for functions and complex expressions
  • Session Management: Track variables and execution history
  • LLM Integration: Automatic provider detection from environment
  • Confidence Formatting: Visual representation of confidence values
  • Built-in Commands: Special REPL commands for session control

REPL Commands

All REPL commands start with : (colon):

| Command | Description | |---------|-------------| | :help | Show available commands and examples | | :vars | Display all variables in current session | | :clear | Clear session (reset all variables) | | :history | Show command history | | :stats | Display session statistics | | :llm | Show LLM provider status | | :exit | Exit the REPL (also Ctrl+D) |

Examples

Basic Usage

prism> 2 + 3
5 (number)

prism> x = 42 ~> 0.9
42 (~90.0%) (confident)

prism> greeting = "Hello, " + "World!"
"Hello, World!" (string)

prism> [1, 2, 3].map(n => n * 2)
[2, 4, 6] (array)

Confidence Values

prism> prediction = "rain" ~> 0.8
"rain" (~80.0%) (confident)

prism> conf = <~ prediction
0.8 (number)

prism> certain = 100 ~> 0.99
100 (~99.0%) (confident)

Functions

prism> add = (a, b) => a + b
[Function: add] (function)

prism> add(5, 3)
8 (number)

prism> greet = (name) => "Hello, " + name + "!"
[Function: greet] (function)

prism> greet("Alice")
"Hello, Alice!" (string)

LLM Integration

prism> response = llm("What is the capital of France?")
"The capital of France is Paris." (~85.0%) (confident)

prism> analysis = llm("Is this code secure?", { temperature: 0.2 })
"Based on my analysis..." (~75.0%) (confident)

Uncertain Control Flow

prism> value = 50 ~> 0.6
50 (~60.0%) (confident)

prism> uncertain if (value) {
...>   high { "High confidence" }
...>   medium { "Medium confidence" }
...>   low { "Low confidence" }
...> }
"Medium confidence" (string)

Session Management

The REPL maintains state between commands:

prism> :vars
Session Variables:
  x: 42 (~90.0%)
  greeting: "Hello, World!"
  prediction: "rain" (~80.0%)
  add: [Function: add]

prism> :stats
Session Statistics:
  Commands executed: 8
  Successful: 7
  Failed: 1
  Session duration: 2m 15s
  Average execution time: 125ms

prism> :clear
Session cleared.

prism> :vars
Session Variables:
  (empty)

Multi-line Input

The REPL automatically detects when more input is needed:

prism> function factorial(n) {
...>   if (n <= 1) {
...>     return 1
...>   }
...>   return n * factorial(n - 1)
...> }
[Function: factorial] (function)

prism> factorial(5)
120 (number)

Error Handling

The REPL provides helpful error messages:

prism> x + y
❌ Error: Variable 'y' is not defined

prism> 1 / 0
Infinity (number)

prism> llm()
❌ Error: Function 'llm' expects at least 1 argument, got 0

Environment Configuration

The REPL automatically detects LLM providers from environment variables:

export CLAUDE_API_KEY=your-claude-key
export GEMINI_API_KEY=your-gemini-key

prism
🚀 Prism REPL v1.0.0
🤖 LLM providers: claude, gemini, mock (default: claude)
Type :help for commands or :exit to quit

prism>

Without API keys:

prism
🚀 Prism REPL v1.0.0
⚠️  Only mock LLM provider available. Set CLAUDE_API_KEY or GEMINI_API_KEY for real AI integration.
Type :help for commands or :exit to quit

prism>

API Reference

PrismREPL Class

The main REPL implementation class:

class PrismREPL {
  constructor()
  
  // Evaluate a line of input
  async evaluate(input: string): Promise<REPLResult>
  
  // Register an LLM provider
  registerLLMProvider(name: string, provider: LLMProvider): void
  
  // Set the default LLM provider
  setDefaultLLMProvider(name: string): void
  
  // Get welcome message
  getWelcomeMessage(): string
  
  // Get current variables
  getVariables(): Record<string, any>
  
  // Clear session
  clearSession(): void
  
  // Get session statistics
  getStatistics(): SessionStats
}

REPLResult Interface

interface REPLResult {
  success: boolean;
  value?: any;
  error?: string;
  type?: string;
  shouldExit?: boolean;
}

Integration

The REPL is designed to be embedded in other applications:

import { PrismREPL } from '@prism-lang/repl';
import { MockLLMProvider } from '@prism-lang/llm';

// Create REPL instance
const repl = new PrismREPL();

// Set up providers
const provider = new MockLLMProvider();
repl.registerLLMProvider('mock', provider);
repl.setDefaultLLMProvider('mock');

// Evaluate code
const result = await repl.evaluate('x = 42 ~> 0.9');
console.log(result.value); // 42 (~90.0%)

Related Packages

License

MIT