CLI Plugin
REPL service for interactive command-line interaction with TokenRing AI agents.
Overview
The @tokenring-ai/cli package provides a Read-Eval-Print Loop (REPL) service for interactive command-line interaction with TokenRing AI agents. It enables users to select or create agents, send chat inputs, execute built-in commands, and handle human interface requests such as confirmations, selections, and multiline inputs.
Key Features
- Interactive agent selection and creation
- Real-time event streaming and display
- Built-in command execution (
/help,/edit, etc.) - Human interface requests (confirmations, selections)
- Multiline input support
- Colored terminal output
- Command auto-completion
Core Components
REPLService
Main REPL implementation managing the interactive CLI loop.
Key Methods:
run(): Starts the REPL loopinjectPrompt(prompt): Queues a prompt to inject into current sessionselectOrCreateAgent(): Prompts user to connect to or create agentsrunAgentLoop(agent): Sets up commands and runs agent-specific loop
REPLInput
Prompt utilities for human-AI interactions.
Key Functions:
askForCommand(options): Gets user input with auto-completionask({ question }): Multi-line editor promptaskForConfirmation(options): Yes/no confirmationaskForSelection({ title, items }): Single list selectionaskForMultipleSelections({ title, items }): Multiple checkbox selectionsaskForSingleTreeSelection(options): Tree-based single selectionaskForMultipleTreeSelection(options): Tree-based multiple selectionopenWebPage({ url }): Opens URL in default browser
Chat Commands
help: Lists all available commands with descriptions
exit/quit: Ends current agent session and returns to selection
multi: Opens Inquirer editor for multiline input
edit: Opens system editor (via EDITOR env) on temp file
Usage Example
import AgentTeam from '@tokenring-ai/agent/AgentTeam';
import REPLService from '@tokenring-ai/cli';
const team = new AgentTeam(/* config */);
const repl = new REPLService(team);
await repl.run(); // Starts interactive CLI
Configuration Options
EDITORenvironment variable: Specifies default editor for/editcommand (defaults tovion Unix,notepadon Windows)- Command auto-completion: Dynamically populated from available commands
- Output styling: Colors and spinners via Chalk/Ora
Dependencies
@tokenring-ai/agent@0.1.0: Core agent management@tokenring-ai/ai-client@0.1.0: AI integration@inquirer/prompts@^7.8.2: Interactive promptschalk@^5.5.0: Terminal stylingora@^8.2.0: Spinners for loadingexeca@^9.6.0: Shell command execution