Package Exports
- lua-cli
Readme
Lua CLI
Build AI agents with custom capabilities using TypeScript.
๐ฏ What is Lua CLI?
Lua CLI is a powerful command-line tool for building, testing, and deploying AI skills. A skill is a collection of tools (functions) that your AI agent can use to accomplish tasks.
Think of it like:
- ๐ค AI Agent = Your assistant (like ChatGPT)
- ๐ฏ Skills = What it can do (your custom capabilities)
- ๐ ๏ธ Tools = Specific functions (e.g., "get weather", "create order")
โก Quick Start
# Install
npm install -g lua-cli
# Authenticate
lua auth configure
# Create a project
mkdir my-skill && cd my-skill
lua init
# Test locally
lua test
# Start dev mode
lua devDone! Your AI skill is running at http://localhost:3000 ๐
๐ฆ Installation
Global Installation (Recommended)
npm install -g lua-cliUsing npx (No Installation)
npx lua-cli [command]Requirements
- Node.js 16.0.0 or higher
- npm 7.0.0 or higher
- TypeScript knowledge (for development)
๐ Features
For Developers
- ๐จ TypeScript-first - Full type safety and autocomplete
- ๐จ Template System - 30+ example tools to learn from
- ๐งช Interactive Testing - Test tools before deployment
- ๐ Live Reload - Dev mode with automatic recompilation
- ๐ฆ Auto Bundling - Dependencies bundled automatically with esbuild
- โ Input Validation - Zod schema validation built-in
For Operations
- ๐ Secure Auth - API key or email OTP authentication
- ๐ Multi-Skill - Multiple skills in one project
- ๐ Version Management - Push, test, and deploy versions
- ๐ฏ Sandbox Testing - Test in isolation before production
- ๐ Environment Variables - Secure configuration management
For Users
- ๐ฌ Chat Interface - Test your AI in real conversations
- ๐ Tool Explorer - Browse and test individual tools
- ๐ Real-time Logs - WebSocket log streaming
- ๐จ Beautiful UI - Modern, intuitive interface
๐ Documentation
๐ For Beginners
Getting Started Guide - Zero to deployed skill in one hour
- Installation and setup
- Your first skill
- Step-by-step tutorial
- Complete restaurant skill example
๐ง For Developers
API Reference - Complete API documentation
- All exported APIs (User, Data, Products, Baskets, Orders)
- Type definitions
- Code examples
- Best practices
Template Guide - Understanding the example project
- Template structure explained
- 30+ tool examples
- Building your first skill
- Common patterns and recipes
๐ป For CLI Users
CLI Reference - All command documentation
- Complete command reference
- Flags and options
- Workflow examples
- Troubleshooting
๐๏ธ For Contributors
Developer Guide - Architecture and internals
- Codebase structure
- Module organization
- Contributing guidelines
๐ Core Concepts
Skills
A skill is a collection of related tools:
import { LuaSkill } from 'lua-cli';
const weatherSkill = new LuaSkill({
name: "weather-skill",
version: "1.0.0",
description: "Provides weather information",
context: "Use get_weather when users ask about weather...",
tools: [
new GetWeatherTool(),
new GetForecastTool()
]
});Tools
A tool is a single function the AI can call:
import { LuaTool } from 'lua-cli';
import { z } from 'zod';
export default class GetWeatherTool implements LuaTool {
name = "get_weather";
description = "Get current weather for a city";
inputSchema = z.object({
city: z.string()
});
async execute(input: any) {
// Call weather API
return {
temperature: 72,
condition: "sunny",
city: input.city
};
}
}Platform APIs
Built-in APIs for common operations:
import { User, Data, Products, Baskets, Orders } from 'lua-cli';
// User data
const user = await User.get();
// Custom data with vector search
await Data.create('movies', movieData, searchText);
const results = await Data.search('movies', 'sci-fi thriller');
// Products
const products = await Products.search('laptop');
// Shopping baskets
const basket = await Baskets.create({ currency: 'USD' });
await Baskets.addItem(basketId, { id, price, quantity });
// Orders
const order = await Baskets.placeOrder(orderData, basketId);๐ก Examples
Example 1: Simple Weather Tool
import { LuaTool } from 'lua-cli';
import { z } from 'zod';
export default class WeatherTool implements LuaTool {
name = "get_weather";
description = "Get weather for any city";
inputSchema = z.object({ city: z.string() });
async execute(input: any) {
const response = await fetch(
`https://api.open-meteo.com/v1/forecast?city=${input.city}`
);
const data = await response.json();
return { temperature: data.temp, condition: data.condition };
}
}Example 2: E-commerce Tool
import { LuaTool, Products, Baskets } from 'lua-cli';
import { z } from 'zod';
export default class AddToCartTool implements LuaTool {
name = "add_to_cart";
description = "Add product to shopping cart";
inputSchema = z.object({
productId: z.string(),
quantity: z.number().min(1)
});
async execute(input: any) {
const product = await Products.getById(input.productId);
const basket = await Baskets.create({ currency: 'USD' });
await Baskets.addItem(basket.id, {
id: input.productId,
price: product.price,
quantity: input.quantity
});
return {
basketId: basket.id,
message: `Added ${input.quantity}x ${product.name} to cart`
};
}
}Example 3: Custom Data with Search
import { LuaTool, Data } from 'lua-cli';
import { z } from 'zod';
export class CreateMovieTool implements LuaTool {
name = "create_movie";
description = "Add a movie to the database";
inputSchema = z.object({
title: z.string(),
director: z.string(),
year: z.number()
});
async execute(input: any) {
const searchText = `${input.title} ${input.director} ${input.year}`;
const movie = await Data.create('movies', input, searchText);
return { id: movie.id, message: 'Movie added' };
}
}
export class SearchMoviesTool implements LuaTool {
name = "search_movies";
description = "Search movies by title, director, or year";
inputSchema = z.object({ query: z.string() });
async execute(input: any) {
const results = await Data.search('movies', input.query, 10, 0.7);
return { movies: results.data, count: results.count };
}
}๐ฏ Commands
Authentication
lua auth configure # Set up API key
lua auth key # Display API key
lua auth logout # Delete API keySkill Management
lua init # Create new skill project
lua compile # Compile TypeScript to deployable format
lua test # Test tools interactively
lua push # Upload version to server
lua deploy # Deploy version to production
lua dev # Development mode with live reloadUtilities
lua admin # Open Lua Admin Dashboard in browser
lua docs # Open documentation in browserSee CLI_REFERENCE.md for complete command documentation.
๐ ๏ธ Development Workflow
Local Development
# Start dev mode
lua dev
# Make changes to src/tools/*.ts
# Save โ Auto-recompiles โ Auto-pushes to sandbox
# Test in browser at http://localhost:3000Testing
# Test individual tools
lua test
# Test conversationally
lua dev
# Use chat interfaceDeployment
# Upload new version
lua push
# Deploy to production
lua deploy๐ Built-in APIs
User API
import { User } from 'lua-cli';
const user = await User.get();Custom Data API (with Vector Search)
import { Data } from 'lua-cli';
await Data.create('collection', data, searchText);
const results = await Data.search('collection', 'query', limit, threshold);Products API
import { Products } from 'lua-cli';
const products = await Products.search('laptop');
await Products.create({ name, price });Baskets API
import { Baskets, BasketStatus } from 'lua-cli';
const basket = await Baskets.create({ currency: 'USD' });
await Baskets.addItem(basketId, { id, price, quantity });Orders API
import { Orders, OrderStatus } from 'lua-cli';
const order = await Baskets.placeOrder(orderData, basketId);
await Orders.updateStatus(OrderStatus.FULFILLED, orderId);See API_REFERENCE.md for complete API documentation.
๐จ Template Project
The template includes 30+ working examples:
- ๐ค๏ธ Weather Tool - External API integration
- ๐ค User Data Tools - User management
- ๐๏ธ Product Tools - E-commerce catalog
- ๐ Basket Tools - Shopping cart
- ๐ฆ Order Tools - Order processing
- ๐ฌ Custom Data Tools - Vector search
- ๐ณ Payment Tool - Payment integration
See TEMPLATE_GUIDE.md for complete template documentation.
๐ Security
- โ API keys stored in system keychain
- โ Environment variables for secrets
- โ Secure VM sandbox for tool execution
- โ No hardcoded credentials
- โ HTTPS for all API calls
Best Practices:
import { env } from 'lua-cli';
// โ
Good - Use environment variables
const apiKey = env('EXTERNAL_API_KEY');
// โ Bad - Hardcoded secrets
const apiKey = 'sk_abc123';๐งช Testing
Unit Testing
import { describe, it, expect } from '@jest/globals';
import MyTool from './tools/MyTool';
describe('MyTool', () => {
it('should return expected result', async () => {
const tool = new MyTool();
const result = await tool.execute({ input: 'test' });
expect(result).toHaveProperty('success');
});
});Interactive Testing
lua test
# Select tool โ Enter inputs โ See resultsConversational Testing
lua dev
# Chat with AI at http://localhost:3000๐ฏ Use Cases
Customer Service
- Answer FAQs from knowledge base
- Look up order status
- Create support tickets
- Search documentation
E-commerce
- Product search and recommendations
- Shopping cart management
- Order creation and tracking
- Inventory checks
Booking & Scheduling
- Check availability
- Create appointments
- Send confirmations
- Manage reservations
Data Management
- CRUD operations on custom data
- Vector search for semantic queries
- Data aggregation and reporting
- Integration with external systems
๐ Architecture
โโโโโโโโโโโโโโโโโโโ
โ AI Agent โ
โ (Lua Platform)โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโ
โ Your Skills โ โ Built with Lua CLI
โ (TypeScript) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโ
โ Your Tools โ
โ (Functions) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโ
โ Platform APIs โ โ User, Products, Data, etc.
โ External APIs โ โ Weather, Stripe, SendGrid, etc.
โ Databases โ โ Your own systems
โโโโโโโโโโโโโโโโโโโ๐ Key Features
Type-Safe Development
// Full TypeScript support
import { LuaTool, Products } from 'lua-cli';
import { z } from 'zod';
// Autocomplete, type checking, and validation
export default class MyTool implements LuaTool {
inputSchema = z.object({
query: z.string() // Validated at runtime
});
async execute(input: z.infer<typeof this.inputSchema>) {
// input is fully typed!
return await Products.search(input.query);
}
}Instant Feedback
lua dev
# Edit file โ Save โ Auto-reload โ Test immediatelyProduction Ready
lua push # Upload to server
lua deploy # Deploy to all users๐ Learning Resources
๐ข New to Lua?
Start here: GETTING_STARTED.md
- Installation
- First skill in 1 hour
- Complete tutorial
- Common patterns
๐ก Building Skills?
Read: API_REFERENCE.md
- All exported APIs
- Type definitions
- Code examples
- Best practices
๐ Understanding Examples?
Read: TEMPLATE_GUIDE.md
- Template structure
- 30+ tool examples
- Common recipes
- Migration guide
๐ต Using the CLI?
Read: CLI_REFERENCE.md
- All commands
- Flags and options
- Workflows
- Troubleshooting
๐ฃ Contributing?
Read: DEVELOPER_GUIDE.md
- Architecture
- Module structure
- Contribution guidelines
๐ง Common Tasks
Create a New Tool
# Create file
touch src/tools/MyTool.tsimport { LuaTool } from 'lua-cli';
import { z } from 'zod';
export default class MyTool implements LuaTool {
name = "my_tool";
description = "What it does";
inputSchema = z.object({ param: z.string() });
async execute(input: any) {
// Your logic here
return { success: true };
}
}Add to skill in src/index.ts:
import MyTool from './tools/MyTool';
const skill = new LuaSkill({
tools: [new MyTool()]
});Call External APIs
import { LuaTool, env } from 'lua-cli';
export default class ExternalApiTool implements LuaTool {
async execute(input: any) {
const apiKey = env('EXTERNAL_API_KEY');
const response = await fetch('https://api.example.com/data', {
headers: { 'Authorization': `Bearer ${apiKey}` }
});
return await response.json();
}
}Use Platform APIs
import { LuaTool, Products, Baskets } from 'lua-cli';
export default class ShoppingTool implements LuaTool {
async execute(input: any) {
// Search products
const products = await Products.search(input.query);
// Create basket
const basket = await Baskets.create({ currency: 'USD' });
// Add item
await Baskets.addItem(basket.id, {
id: products.data[0].id,
price: products.data[0].price,
quantity: 1
});
return { basketId: basket.id };
}
}Store Custom Data
import { LuaTool, Data } from 'lua-cli';
export default class SaveNoteTool implements LuaTool {
async execute(input: any) {
// Create
const note = await Data.create('notes', {
title: input.title,
content: input.content,
tags: input.tags
}, `${input.title} ${input.content}`);
// Search later
const results = await Data.search('notes', 'meeting notes', 10);
return { noteId: note.id };
}
}๐ฏ Example Projects
Knowledge Base Assistant
Tools: search_kb, create_article, update_article
APIs: Data (vector search)
Use Case: Company documentation, FAQE-commerce Bot
Tools: search_products, add_to_cart, checkout
APIs: Products, Baskets, Orders
Use Case: Online shopping assistantBooking System
Tools: check_availability, make_reservation, cancel_booking
APIs: Data (custom collections)
Use Case: Restaurant/hotel reservationsCRM Assistant
Tools: find_customer, create_lead, update_contact
APIs: Data, User
Use Case: Customer relationship management๐ Deployment
Development โ Production Flow
# 1. Develop locally
lua dev
# Edit, test, iterate
# 2. Push to server
lua push
# 3. Test in sandbox
lua dev
# Final testing
# 4. Deploy to production
lua deploy
# Available to all users!Version Management
Update version in lua.skill.yaml:
skills:
- name: my-skill
version: 1.0.1 # โ Increment thisThen push and deploy:
lua push # Uploads v1.0.1
lua deploy # Deploys v1.0.1โ๏ธ Configuration
Environment Variables
.env file:
STRIPE_API_KEY=sk_test_abc123
SENDGRID_KEY=SG.xyz789
CUSTOM_API_URL=https://api.example.comlua.skill.yaml:
skill:
env:
PRODUCTION_API_KEY: sk_live_abc123
BASE_URL: https://prod.example.comAccess in code:
import { env } from 'lua-cli';
const key = env('STRIPE_API_KEY');๐ค Contributing
We welcome contributions!
- Fork the repository
- Create a feature branch
- Make your changes
- Write tests
- Submit a pull request
See DEVELOPER_GUIDE.md for architecture details.
๐ License
MIT License - see LICENSE file for details.
๐ Links
- Documentation: https://docs.heylua.ai
- Platform: https://heylua.ai
- GitHub: https://github.com/lua-ai/lua-cli
- npm: https://www.npmjs.com/package/lua-cli
๐ฌ Support
- Issues: GitHub Issues
- Email: support@lua.ai
- Docs: https://docs.heylua.ai
๐ Quick Links
| I want to... | Read this... |
|---|---|
| Get started | GETTING_STARTED.md |
| Learn the API | API_REFERENCE.md |
| Use CLI commands | CLI_REFERENCE.md |
| Understand examples | TEMPLATE_GUIDE.md |
| Contribute code | DEVELOPER_GUIDE.md |
| See changelog | CHANGELOG.md |
Happy building! ๐
Made with โค๏ธ by the Lua team