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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@memberjunction/ai-cli

v5.23.0

Published

MemberJunction AI agent, prompt and action execution CLI, integrated with the main MJ CLI.

Downloads

3,808

Readme

@memberjunction/ai-cli

Command-line interface for executing MemberJunction AI agents, prompts, and actions. Built on the oclif framework, it provides both one-shot and interactive modes with rich terminal output, conversation history management, audit logging, and direct database integration.

Note: The standalone mj-ai binary is deprecated. All AI functionality has been integrated into the main MemberJunction CLI. Use mj ai commands instead.

Architecture

graph TD
    subgraph "@memberjunction/ai-cli"
        CLI["oclif CLI Framework<br/>mj-ai binary"]
        style CLI fill:#2d8659,stroke:#1a5c3a,color:#fff

        subgraph "Commands"
            AL["agents list"]
            style AL fill:#7c5295,stroke:#563a6b,color:#fff
            AR["agents run"]
            style AR fill:#7c5295,stroke:#563a6b,color:#fff
            PL["prompts list"]
            style PL fill:#7c5295,stroke:#563a6b,color:#fff
            PRR["prompts run"]
            style PRR fill:#7c5295,stroke:#563a6b,color:#fff
            ACL["actions list"]
            style ACL fill:#7c5295,stroke:#563a6b,color:#fff
            ACR["actions run"]
            style ACR fill:#7c5295,stroke:#563a6b,color:#fff
        end

        subgraph "Services"
            AS["AgentService"]
            style AS fill:#b8762f,stroke:#8a5722,color:#fff
            PS["PromptService"]
            style PS fill:#b8762f,stroke:#8a5722,color:#fff
            ACS["ActionService"]
            style ACS fill:#b8762f,stroke:#8a5722,color:#fff
            CS["ConversationService"]
            style CS fill:#b8762f,stroke:#8a5722,color:#fff
            VS["ValidationService"]
            style VS fill:#b8762f,stroke:#8a5722,color:#fff
            AAS["AgentAuditService"]
            style AAS fill:#b8762f,stroke:#8a5722,color:#fff
        end

        subgraph "Utilities"
            OF["OutputFormatter"]
            style OF fill:#2d6a9f,stroke:#1a4971,color:#fff
            TF["TextFormatter"]
            style TF fill:#2d6a9f,stroke:#1a4971,color:#fff
            CM["ConsoleManager"]
            style CM fill:#2d6a9f,stroke:#1a4971,color:#fff
            EL["ExecutionLogger"]
            style EL fill:#2d6a9f,stroke:#1a4971,color:#fff
        end
    end

    CLI --> AL
    CLI --> AR
    CLI --> PL
    CLI --> PRR
    CLI --> ACL
    CLI --> ACR

    AR --> AS
    PRR --> PS
    ACR --> ACS
    AS --> CS
    AS --> AAS

Installation

npm install -g @memberjunction/ai-cli

Commands

Agent Commands

# List all available agents
mj-ai agents list

# List agents with filtering
mj-ai agents list --filter "sales"

# Run an agent interactively (chat mode)
mj-ai agents run --name "Sales Assistant"

# Run an agent with a single message
mj-ai agents run --name "Data Analyzer" --message "Show Q3 revenue by region"

# Run an agent by ID
mj-ai agents run --id "agent-uuid"

Prompt Commands

# List all available prompts
mj-ai prompts list

# Run a prompt with data
mj-ai prompts run --name "Summarize Content" --data '{"content": "Long text..."}'

# Run a prompt with a file
mj-ai prompts run --name "Analyze Document" --file ./report.txt

Action Commands

# List all available actions
mj-ai actions list

# Run an action with parameters
mj-ai actions run --name "Send Email" --params '{"to": "[email protected]", "subject": "Test"}'

Key Features

Interactive Chat Mode

When running an agent without --message, the CLI enters interactive chat mode with:

  • Multi-line input support
  • Conversation history across turns
  • Real-time progress indicators (spinners)
  • Formatted markdown output
  • Color-coded output for different message types

Conversation Management

The ConversationService manages conversation state:

  • Creates and tracks MJ Conversation entities
  • Maintains message history across agent turns
  • Supports conversation resumption

Audit Logging

The AgentAuditService provides detailed execution audit trails:

  • Token usage tracking per turn
  • Cost estimation
  • Execution time tracking
  • Action execution logging
  • Error recording

Output Formatting

Rich terminal output with:

  • Markdown rendering via TextFormatter
  • Tabular data display via table package
  • Color-coded status messages via chalk
  • Spinner animations via ora-classic
  • Structured JSON output option

Database Integration

Direct SQL Server connection for:

  • Loading agent, prompt, and action metadata
  • Storing conversation history
  • Recording execution logs
  • User context resolution

Configuration

Configure via mj.config.cjs, .mjrc, or environment variables:

module.exports = {
    databaseSettings: {
        host: 'localhost',
        port: 1433,
        database: 'MemberJunction',
        username: 'sa',
        password: 'password'
    }
};

Required environment variables:

  • DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD -- Database connection
  • AI_VENDOR_API_KEY__OPENAILLM -- OpenAI API key (or other provider keys)

Dependencies

  • @oclif/core -- CLI framework
  • @memberjunction/ai-agents -- AgentRunner for agent execution
  • @memberjunction/ai-prompts -- AIPromptRunner for prompt execution
  • @memberjunction/ai-core-plus -- Shared types
  • @memberjunction/ai -- Core AI abstractions
  • @memberjunction/actions -- Action execution
  • @memberjunction/core / @memberjunction/core-entities -- MJ framework
  • @memberjunction/sqlserver-dataprovider -- SQL Server data access
  • @memberjunction/core-entities-server -- Server-side entity extensions
  • @inquirer/prompts -- Interactive prompts
  • chalk -- Terminal colors
  • ora-classic -- Terminal spinners
  • table -- Tabular output
  • cosmiconfig -- Configuration loading