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

@catalystlabs/tryai-cli

v1.0.1

Published

CLI tool for TryAI - The Rails of AI Integration

Readme

TryAI CLI

The TryAI CLI is a comprehensive command-line tool that extends the TryAI library with interactive prompt execution, template management, and database synchronization capabilities.

Features

  • Zero-config setup - Works out of the box
  • Interactive REPL mode - Chat with AI models directly
  • Template management - Database-backed template versioning
  • Batch processing - Process multiple inputs efficiently
  • Cost tracking - Monitor your AI usage and costs
  • Testing & benchmarking - Validate template performance
  • Template Studio - Web-based template editor (coming soon)

Installation

npm install -g @catalystlabs/tryai-cli

Quick Start

# Initialize templates (creates .tryai/config.ts and database)
tryai templates init

# Run a simple prompt
tryai prompt "Explain quantum computing in simple terms"

# Start interactive mode
tryai interactive

# Start chat mode
tryai chat --model gpt-4o

# Run a template with variables
tryai run my-template --var name=John --var topic="AI"

Commands

Basic Commands

tryai prompt <text>

Execute a simple prompt with AI.

tryai prompt "Write a haiku about coding"
tryai prompt "Explain REST APIs" --model claude-3-5-sonnet --format markdown
tryai prompt "Analyze this data" --system "You are a data scientist" --max-tokens 500

Options:

  • -m, --model <model> - Model to use (default: gpt-4o-mini)
  • -s, --stream - Stream the response
  • -f, --format <format> - Output format (json|markdown|plain)
  • -o, --output <file> - Save output to file
  • --max-tokens <number> - Maximum tokens to generate
  • --temperature <number> - Temperature (0-2)
  • --system <text> - System prompt

tryai run <template>

Run a template with variables.

tryai run code-review --var language=python --var code="def hello(): print('hi')"
tryai run email-writer --var tone=professional --var purpose="meeting request"

Options:

  • -v, --var <key=value...> - Template variables
  • -m, --model <model> - Model to use
  • -s, --stream - Stream the response
  • -f, --format <format> - Output format
  • -o, --output <file> - Save output to file

Interactive Modes

tryai interactive (alias: tryai i)

Start interactive REPL mode with a rich UI.

Features:

  • Real-time chat with AI
  • Slash commands (/help, /clear, /model, /cost, /exit)
  • Token and cost tracking
  • Model switching
  • Conversation history

tryai chat

Start conversation mode in terminal.

tryai chat --model gpt-4o --system "You are a helpful coding assistant"

Options:

  • -m, --model <model> - Model to use
  • -s, --system <text> - System prompt
  • --max-tokens <number> - Maximum tokens
  • --temperature <number> - Temperature

Template Management

tryai templates init

Initialize template database and configuration.

Creates:

  • .tryai/config.ts - Configuration file
  • .tryai/templates.db - SQLite database (or configured database)

tryai templates list (alias: tryai templates ls)

List all available templates.

tryai templates list

tryai templates show <name>

Show template details including variables and configuration.

tryai templates show code-review

tryai templates push <file>

Push a template file to the database.

tryai templates push ./templates/email-writer.toml --name email-writer

Template file format (TOML):

[metadata]
description = "Professional email writer"
author = "Your Name"
version = "1.0.0"
tags = ["email", "business", "communication"]

[config]
model = "gpt-4o"
temperature = 0.7
max_tokens = 500

[variables]
[variables.recipient]
type = "string"
description = "Email recipient name"
required = true

[variables.purpose]
type = "string"
description = "Purpose of the email"
required = true

[variables.tone]
type = "string"
description = "Email tone"
default = "professional"

prompt = """
Write a {{tone}} email to {{recipient}} about {{purpose}}.

Make it clear, concise, and appropriate for a business context.
"""

tryai templates pull <name>

Pull a template from database to file.

tryai templates pull email-writer --output email-writer.toml

tryai templates diff <name>

Show changes between template versions.

tryai templates diff email-writer --version 2

Batch Processing

tryai batch <command>

Process multiple inputs in batch.

# From JSON array file
tryai batch "Summarize: \${input}" --input prompts.json --output results.json

# From newline-delimited file
tryai batch "Translate to Spanish: \${input}" --input sentences.txt --concurrency 5

Input file formats:

  • JSON array: ["text 1", "text 2", "text 3"]
  • Newline-delimited: Each line is a separate input

Options:

  • -i, --input <file> - Input file (required)
  • -o, --output <file> - Output file
  • -c, --concurrency <number> - Concurrent requests (default: 3)
  • -m, --model <model> - Model to use

Testing & Benchmarking

tryai test <template>

Test a template with sample data.

tryai test email-writer --var recipient=John --var purpose="meeting" --samples 5
tryai test json-parser --validate-json --samples 10

Options:

  • -v, --var <key=value...> - Template variables
  • -s, --samples <number> - Number of test samples (default: 1)
  • --validate-json - Validate JSON output format
  • --validate-schema <file> - Validate against JSON schema

tryai benchmark <template>

Performance benchmark a template.

tryai benchmark code-review --iterations 50 --concurrency 3
tryai benchmark fast-summary --iterations 100 --warmup 5

Options:

  • -n, --iterations <number> - Number of iterations (default: 10)
  • -c, --concurrency <number> - Concurrent requests (default: 1)
  • --warmup <number> - Warmup iterations (default: 2)

Statistics & Environment

tryai stats

Show usage statistics.

tryai stats --detailed

tryai env list

List current configuration.

tryai env list

tryai env use <provider> [model]

Set default provider and model.

tryai env use openai gpt-4o
tryai env use anthropic claude-3-5-sonnet

Configuration

Config File Structure

The CLI creates a .tryai/config.ts file for configuration:

import type { TryAIConfig } from '@catalystlabs/tryai-cli';

const config: TryAIConfig = {
  defaultModel: 'gpt-4o-mini',
  defaultProvider: 'openai',
  
  // Template database configuration
  templates: {
    database: {
      type: 'sqlite',
      connection: '.tryai/templates.db'
    }
  },
  
  // API keys (can also use environment variables)
  apiKeys: {
    openai: process.env.OPENAI_API_KEY,
    anthropic: process.env.ANTHROPIC_API_KEY,
    google: process.env.GOOGLE_API_KEY,
    llama: process.env.LLAMA_API_KEY,
  }
};

export default config;

Environment Variables

Set API keys via environment variables:

export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"
export GOOGLE_API_KEY="your-key-here"
export LLAMA_API_KEY="your-key-here"

Database Support

The CLI supports multiple database types for template storage:

  • SQLite (default): Local file-based database
  • PostgreSQL: For team/production use
  • MySQL: Alternative production option
// PostgreSQL example
templates: {
  database: {
    type: 'postgres',
    connection: 'postgresql://user:password@localhost:5432/tryai'
  }
}

// MySQL example
templates: {
  database: {
    type: 'mysql',
    connection: 'mysql://user:password@localhost:3306/tryai'
  }
}

Examples

Creating a Code Review Template

  1. Create code-review.toml:
[metadata]
description = "AI-powered code review assistant"
tags = ["code", "review", "quality"]

[config]
model = "gpt-4o"
temperature = 0.3

[variables]
[variables.language]
type = "string"
description = "Programming language"
required = true

[variables.code]
type = "string"
description = "Code to review"
required = true

[variables.focus]
type = "string"
description = "Review focus (security, performance, style)"
default = "general"

prompt = """
Review this {{language}} code with focus on {{focus}}:

```{{language}}
{{code}}

Provide:

  1. Overall assessment
  2. Specific issues found
  3. Suggestions for improvement
  4. Security considerations (if applicable)

Be constructive and educational in your feedback. """


2. Push to database:

```bash
tryai templates push code-review.toml
  1. Use the template:
tryai run code-review \
  --var language=python \
  --var focus=security \
  --var code="def authenticate(password): return password == 'admin'"

Batch Processing Example

Process multiple code files for review:

  1. Create files.json:
[
  "def user_login(pwd): return pwd == 'password123'",
  "SELECT * FROM users WHERE id = '" + user_id + "'",
  "function validateEmail(email) { return true; }"
]
  1. Run batch review:
tryai batch "Review this code for security issues: \${input}" \
  --input files.json \
  --output security-review.json \
  --model gpt-4o \
  --concurrency 3

Performance Testing

Test and benchmark your templates:

# Test with various inputs
tryai test code-review \
  --var language=javascript \
  --var code="console.log('test')" \
  --samples 10

# Benchmark performance
tryai benchmark code-review \
  --iterations 50 \
  --concurrency 3 \
  --warmup 5

Coming Soon

  • Template Studio: Web-based template editor with visual workflow builder
  • Team Collaboration: Share templates across team members
  • Template Marketplace: Discover and share templates with the community
  • Advanced Analytics: Detailed usage and performance analytics
  • CI/CD Integration: Template testing in continuous integration pipelines

Support

For issues and feature requests, visit: GitHub Issues

License

MIT License - see LICENSE file for details.