lua-cli 3.0.0-alpha.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +864 -0
  2. package/dist/api/chat.api.service.d.ts +8 -0
  3. package/dist/api/chat.api.service.js +55 -0
  4. package/dist/api/products.api.service.d.ts +2 -1
  5. package/dist/api/products.api.service.js +11 -10
  6. package/dist/api-exports.d.ts +1 -1
  7. package/dist/api-exports.js +6 -1
  8. package/dist/commands/chat.js +35 -32
  9. package/dist/commands/init.js +10 -2
  10. package/dist/index.js +2 -2
  11. package/dist/interfaces/message.d.ts +2 -2
  12. package/dist/utils/agent-management.d.ts +1 -1
  13. package/dist/utils/agent-management.js +5 -3
  14. package/dist/utils/init-helpers.d.ts +10 -1
  15. package/dist/utils/init-helpers.js +44 -1
  16. package/dist/utils/pre-bundle-jobs.js +9 -9
  17. package/dist/utils/sandbox.js +1 -2
  18. package/package.json +3 -3
  19. package/template/QUICKSTART.md +693 -191
  20. package/template/README.md +673 -802
  21. package/template/package.json +1 -1
  22. package/template/src/index.ts +18 -252
  23. package/template/src/postprocessors/modifyResponse.ts +21 -0
  24. package/template/src/preprocessors/messageMatching.ts +22 -0
  25. package/template/src/skills/basket.skill.ts +12 -0
  26. package/template/src/skills/product.skill.ts +13 -0
  27. package/template/src/{tools → skills/tools}/ProductsTool.ts +2 -1
  28. package/template/src/skills/tools/UserDataTool.ts +75 -0
  29. package/template/src/skills/user.skill.ts +13 -0
  30. package/template/src/seed.ts +0 -46
  31. package/template/src/tools/UserDataTool.ts +0 -33
  32. /package/template/src/{tools → skills/tools}/BasketTool.ts +0 -0
  33. /package/template/src/{tools → skills/tools}/CreateInlineJob.ts +0 -0
  34. /package/template/src/{tools → skills/tools}/CreatePostTool.ts +0 -0
  35. /package/template/src/{tools → skills/tools}/CustomDataTool.ts +0 -0
  36. /package/template/src/{tools → skills/tools}/GameScoreTrackerTool.ts +0 -0
  37. /package/template/src/{tools → skills/tools}/GetWeatherTool.ts +0 -0
  38. /package/template/src/{tools → skills/tools}/OrderTool.ts +0 -0
  39. /package/template/src/{tools → skills/tools}/PaymentTool.ts +0 -0
  40. /package/template/src/{tools → skills/tools}/SmartBasketTool.ts +0 -0
@@ -1,1084 +1,955 @@
1
- # Your Lua AI Skill Project
1
+ # 🤖 Lua AI Agent Template
2
2
 
3
- Welcome to your Lua AI skill project! This project is ready to customize and deploy.
3
+ Welcome to your Lua AI Agent! This is a fully-featured template to help you build, test, and deploy intelligent AI agents with custom tools, webhooks, scheduled jobs, and message processors.
4
4
 
5
- ---
6
-
7
- ## 🎯 What You Have
5
+ ## 🎯 What You've Got
8
6
 
9
- This project includes:
10
- - ✅ **LuaAgent** - New simplified agent configuration (RECOMMENDED!)
11
- - ✅ **7 Example Skills** - Pre-configured skill examples
12
- - ✅ **30+ Example Tools** - Working tool implementations
13
- - ✅ **2 Webhook Examples** - HTTP endpoints for external integrations
14
- - ✅ **4 Job Examples** - Scheduled tasks (cron, interval, one-time)
15
- - ✅ **Smart Basket Example** - Dynamic job creation from tools
16
- - ✅ **All Platform APIs** - User, Products, Baskets, Orders, Custom Data, Webhooks, Jobs
17
- - ✅ **TypeScript Setup** - Full type safety
18
- - ✅ **Ready to Deploy** - Just customize and go!
7
+ This template includes **everything you need** to create a production-ready AI agent:
19
8
 
20
- > **NEW!** Check out `AGENT_CONFIGURATION.md` to learn about the simplified `LuaAgent` approach.
21
- > It's easier and cleaner than the legacy approach!
9
+ - **LuaAgent Configuration** - Unified agent setup with persona and welcome message
10
+ - **Example Skills & Tools** - 30+ pre-built tools demonstrating best practices
11
+ - ✅ **Webhooks** - HTTP endpoints for external integrations
12
+ - ✅ **Scheduled Jobs** - Automated background tasks
13
+ - ✅ **Message Processors** - Pre/post-process conversations
14
+ - ✅ **Type Safety** - Full TypeScript support with Zod validation
15
+ - ✅ **Testing Suite** - Local testing before deployment
16
+ - ✅ **CI/CD Ready** - Batch deployment commands
22
17
 
23
18
  ---
24
19
 
25
20
  ## 🚀 Quick Start
26
21
 
22
+ **New to Lua?** Start here:
23
+
27
24
  ```bash
28
- # 1. Test a tool locally
29
- npm run test
30
- # or
25
+ # 1. Test your tools locally
31
26
  lua test
32
27
 
33
- # 2. Start development mode (live reload + chat interface)
34
- npm run dev
35
- # or
36
- lua dev
37
-
38
- # 3. Push to server
39
- npm run push
40
- # or
41
- lua push
28
+ # 2. Chat with your agent (sandbox mode)
29
+ lua chat
42
30
 
43
- # 4. Deploy to production
44
- lua deploy
31
+ # 3. Deploy to production
32
+ lua push all --force --auto-deploy
45
33
  ```
46
34
 
47
- **Your AI is now live!** 🎉
48
-
49
- ---
50
-
51
- ## 📁 Project Structure
52
-
53
- ```
54
- your-project/
55
- ├── src/
56
- │ ├── index.ts # YOUR STARTING POINT - Define skills here
57
- │ └── tools/ # Tool implementations
58
- │ ├── GetWeatherTool.ts # External API example
59
- │ ├── UserDataTool.ts # User API example
60
- │ ├── ProductsTool.ts # Products API (6 tools)
61
- │ ├── BasketTool.ts # Baskets API (9 tools)
62
- │ ├── OrderTool.ts # Orders API (4 tools)
63
- │ ├── CustomDataTool.ts # Custom Data API (6 tools)
64
- │ ├── PaymentTool.ts # Payment integration
65
- │ └── CreatePostTool.ts # Simple example
66
- ├── lua.skill.yaml # Configuration (auto-managed)
67
- ├── package.json # Dependencies
68
- ├── tsconfig.json # TypeScript config
69
- ├── .env # Environment variables (create this)
70
- └── README.md # This file
71
- ```
35
+ 👉 **[Read the Full Quick Start Guide →](QUICKSTART.md)**
72
36
 
73
37
  ---
74
38
 
75
- ## 🎓 Getting Started
39
+ ## 📦 What's Inside
76
40
 
77
- ### Step 1: Choose Your Configuration Style
41
+ ### Core Files
78
42
 
79
- **Option A: LuaAgent (Recommended for new projects)**
43
+ | File | Purpose |
44
+ |------|---------|
45
+ | `src/index.ts` | **Main file** - LuaAgent configuration |
46
+ | `lua.skill.yaml` | Agent metadata and component registry |
47
+ | `.env` | Environment variables (API keys, secrets) |
80
48
 
81
- The simplified approach - define everything in one place:
82
-
83
- ```typescript
84
- import { LuaAgent, LuaSkill } from 'lua-cli';
49
+ ### Directory Structure
85
50
 
86
- export const agent = new LuaAgent({
87
- name: 'my-assistant',
88
- persona: 'You are a helpful e-commerce assistant...',
89
- welcomeMessage: 'Hello! How can I help you today?',
90
- skills: [weatherSkill, productSkill, basketSkill],
91
- webhooks: [userWebhook],
92
- jobs: [healthCheckJob]
93
- });
51
+ ```
52
+ src/
53
+ ├── index.ts # 🎯 LuaAgent - Your agent's configuration
54
+ ├── skills/ # Tools grouped by functionality
55
+ │ ├── tools/ # Individual tool implementations
56
+ │ │ ├── GetWeatherTool.ts # Example: External API integration
57
+ │ │ ├── ProductsTool.ts # Example: CRUD operations
58
+ │ │ ├── BasketTool.ts # Example: Shopping cart
59
+ │ │ └── SmartBasketTool.ts # Example: Complex tool with state
60
+ │ ├── product.skill.ts # Skill that groups product tools
61
+ │ └── basket.skill.ts # Skill that groups basket tools
62
+ ├── webhooks/ # HTTP endpoints
63
+ │ ├── PaymentWebhook.ts # Example: Payment notifications
64
+ │ └── UserEventWebhook.ts # Example: External events
65
+ ├── jobs/ # Scheduled tasks
66
+ │ ├── DailyCleanupJob.ts # Example: Recurring cleanup
67
+ │ └── HealthCheckJob.ts # Example: Monitoring job
68
+ ├── preprocessors/ # Before-message processing
69
+ │ └── messageMatching.ts # Example: Route messages
70
+ └── postprocessors/ # After-response processing
71
+ └── modifyResponse.ts # Example: Format responses
94
72
  ```
95
73
 
96
- See `src/index-agent-example.ts` and `AGENT_CONFIGURATION.md` for details.
74
+ ---
97
75
 
98
- **Option B: Individual Components (Legacy)**
76
+ ## 🤖 Your Agent at a Glance
99
77
 
100
- Open **`src/index.ts`** - this is where your skills are defined:
78
+ Your agent is configured in `src/index.ts`:
101
79
 
102
80
  ```typescript
103
- // Example: General purpose skill
104
- const generalSkill = new LuaSkill({
105
- name: "general-skill",
106
- version: "0.0.2",
107
- description: "Weather and utility tools",
108
- context: "Use get_weather for weather info...",
109
- tools: [
110
- new GetWeatherTool(),
111
- new CreatePostTool()
81
+ export const agent = new LuaAgent({
82
+ name: 'your-agent-name',
83
+ persona: 'Your agent personality and behavior...',
84
+ welcomeMessage: 'First message users see',
85
+
86
+ skills: [
87
+ generalSkill, // Weather, posts, utils
88
+ userSkill, // User data management
89
+ productSkill, // Product operations
90
+ basketSkill, // Shopping cart
91
+ orderSkill, // Order processing
92
+ customDataSkill, // Custom data storage
93
+ paymentSkill // Payment processing
94
+ ],
95
+
96
+ webhooks: [
97
+ // paymentWebhook, // Uncomment to enable
98
+ ],
99
+
100
+ jobs: [
101
+ // dailyCleanupJob, // Uncomment to enable
102
+ ],
103
+
104
+ preProcessors: [
105
+ // messageMatchingProcessor, // Uncomment to enable
106
+ ],
107
+
108
+ postProcessors: [
109
+ // responseModifierProcessor, // Uncomment to enable
112
110
  ]
113
111
  });
114
112
  ```
115
113
 
116
- **You have 7 skills pre-configured:**
117
- 1. `general-skill` - Weather and posts
118
- 2. `user-data-skill` - User management
119
- 3. `product-skill` - Product catalog
120
- 4. `basket-skill` - Shopping carts
121
- 5. `order-skill` - Order processing
122
- 6. `custom-data-skill` - Custom data (movies example)
123
- 7. `payment-skill` - Payment links
124
-
125
114
  ---
126
115
 
127
- ### Step 2: Test the Examples
116
+ ## 🛠️ Example Tools Included
128
117
 
129
- ```bash
130
- lua test
131
- ```
118
+ ### General Purpose
119
+ - **get_weather** - Fetch weather data from external API
120
+ - **create_post** - Create posts with external service
121
+ - **create_inline_job** - Demonstrates dynamic job creation
122
+
123
+ ### User Management
124
+ - **get_user_data** - Retrieve user information
125
+ - **update_user_data** - Update user profiles
132
126
 
133
- **Try these tools:**
134
- - `get_weather` - Enter city: "London"
135
- - `search_products` - Enter query: "laptop"
136
- - `create_movie` - Enter title, director, year
137
- - `get_user_data` - No input needed
127
+ ### E-commerce
128
+ - **search_products** - Search product catalog
129
+ - **create_product** - Add new products
130
+ - **update_product** - Modify existing products
131
+ - **delete_product** - Remove products
132
+ - **create_basket** - Create shopping cart
133
+ - **add_item_to_basket** - Add products to cart
134
+ - **checkout_basket** - Complete purchase
135
+ - **create_order** - Place orders
136
+ - **update_order_status** - Track order progress
137
+
138
+ ### Advanced Examples
139
+ - **smart_basket_tool** - Complex state management with AI-powered recommendations
140
+ - **game_score_tracker** - Multi-player game tracking with leaderboards
141
+ - **create_payment_link** - Stripe integration for payments
138
142
 
139
143
  ---
140
144
 
141
- ### Step 3: Start Dev Mode
145
+ ## 🎓 Learning Path
142
146
 
143
- ```bash
144
- lua dev
145
- ```
147
+ ### Beginner
148
+ 1. ✅ Read [QUICKSTART.md](QUICKSTART.md)
149
+ 2. ✅ Run `lua test` to try existing tools
150
+ 3. ✅ Run `lua chat` to interact with your agent
151
+ 4. ✅ Modify the agent persona in `src/index.ts`
146
152
 
147
- **Opens chat interface at http://localhost:3000**
153
+ ### Intermediate
154
+ 1. ✅ Create your first custom tool
155
+ 2. ✅ Group tools into a skill
156
+ 3. ✅ Add the skill to your LuaAgent
157
+ 4. ✅ Test and deploy with `lua push`
148
158
 
149
- **Try chatting:**
150
- - "What's the weather in Tokyo?"
151
- - "Show me your products"
152
- - "Create a shopping basket"
153
- - "Add product XYZ to my basket"
159
+ ### Advanced
160
+ 1. Create webhooks for external integrations
161
+ 2. Schedule jobs for automated tasks
162
+ 3. Add preprocessors to route/filter messages
163
+ 4. Use postprocessors to format responses
164
+ 5. ✅ Implement complex tools with external APIs
154
165
 
155
166
  ---
156
167
 
157
- ### Step 4: Customize for Your Use Case
168
+ ## 🔑 Key Features
158
169
 
159
- #### Option A: Modify Existing Tools
160
-
161
- Edit `src/tools/GetWeatherTool.ts`:
170
+ ### Intelligent Tools
171
+ Your agent can use tools to accomplish tasks:
162
172
  ```typescript
163
- async execute(input: any) {
164
- const weather = await this.getWeather(input.city);
165
-
166
- // Add your customization
167
- return {
168
- ...weather,
169
- recommendation: this.getClothingAdvice(weather.temperature)
170
- };
171
- }
173
+ // User: "What's the weather in Tokyo?"
174
+ // Agent uses: get_weather tool
175
+ // Response: "It's 72°F and sunny in Tokyo"
172
176
  ```
173
177
 
174
- #### Option B: Remove Unused Skills
175
-
176
- Clean up `src/index.ts`:
178
+ ### External Integrations
179
+ Connect to any API:
177
180
  ```typescript
178
- // Remove skills you don't need
179
- // Keep only what's relevant to your use case
181
+ // Stripe, OpenAI, Pinecone, custom APIs
182
+ const result = await axios.post(API_URL, data);
183
+ ```
180
184
 
181
- import { LuaSkill } from "lua-cli";
182
- import GetWeatherTool from "./tools/GetWeatherTool";
185
+ ### User Context
186
+ Access user data in every tool:
187
+ ```typescript
188
+ const user = await User.get();
189
+ const preferences = user.preferences;
190
+ ```
183
191
 
184
- const mySkill = new LuaSkill({
185
- name: "my-custom-skill",
186
- version: "1.0.0",
187
- description: "My specific use case",
188
- context: "Clear instructions for the AI...",
189
- tools: [
190
- new GetWeatherTool()
191
- // Add your tools
192
- ]
192
+ ### Persistent Storage
193
+ Store data across conversations:
194
+ ```typescript
195
+ await Data.create('notes', {
196
+ title: "Meeting Notes",
197
+ content: "..."
193
198
  });
194
199
  ```
195
200
 
196
- #### Option C: Create New Tools
197
-
198
- Create `src/tools/MyTool.ts`:
201
+ ### Scheduled Automation
202
+ Run tasks on a schedule:
199
203
  ```typescript
200
- import { LuaTool } from "lua-cli";
201
- import { z } from "zod";
202
-
203
- export default class MyTool implements LuaTool {
204
- name = "my_tool";
205
- description = "What my tool does";
206
-
207
- inputSchema = z.object({
208
- param: z.string()
209
- });
210
-
211
- async execute(input: z.infer<typeof this.inputSchema>) {
212
- // Your logic here
213
- return { success: true };
214
- }
204
+ // Every day at 9 AM
205
+ schedule: {
206
+ type: "cron",
207
+ pattern: "0 9 * * *"
215
208
  }
216
209
  ```
217
210
 
218
- Add to `src/index.ts`:
211
+ ### Real-time Events
212
+ Receive HTTP webhooks:
219
213
  ```typescript
220
- import MyTool from "./tools/MyTool";
221
-
222
- const mySkill = new LuaSkill({
223
- tools: [new MyTool()]
224
- });
214
+ // POST /webhook/{webhookId}
215
+ // Process payment confirmations, order updates, etc.
225
216
  ```
226
217
 
227
218
  ---
228
219
 
229
- ## 🛠️ Tool Examples Explained
220
+ ## 📊 Development Workflow
230
221
 
231
- ### GetWeatherTool.ts
232
- **What it does:** Fetches weather for any city using Open-Meteo API (free, no key required)
233
-
234
- **Learn from this:**
235
- - External API integration
236
- - Error handling for API calls
237
- - Data transformation
238
-
239
- **Use it for:**
240
- - Weather information
241
- - Location-based services
242
- - External API patterns
243
-
244
- ---
245
-
246
- ### UserDataTool.ts
247
- **What it does:** Gets and updates user data (2 tools)
222
+ ```mermaid
223
+ graph LR
224
+ A[Write Code] --> B[lua test]
225
+ B --> C[lua chat sandbox]
226
+ C --> D{Works?}
227
+ D -->|No| A
228
+ D -->|Yes| E[lua compile]
229
+ E --> F[lua push]
230
+ F --> G[lua chat production]
231
+ G --> H{Deploy?}
232
+ H -->|Yes| I[lua deploy]
233
+ H -->|No| A
234
+ ```
248
235
 
249
- **Learn from this:**
250
- - Using Platform APIs (`User`)
251
- - Simple CRUD operations
252
- - Data retrieval and updates
236
+ ### Commands Reference
253
237
 
254
- **Use it for:**
255
- - User profile management
256
- - Preference storage
257
- - User-specific data
238
+ | Command | Purpose | When to Use |
239
+ |---------|---------|-------------|
240
+ | `lua test` | Test individual tools | During development |
241
+ | `lua chat` | Interactive testing | Validate tool interactions |
242
+ | `lua compile` | Bundle your code | Before pushing |
243
+ | `lua push` | Upload to server | Ready to deploy |
244
+ | `lua deploy` | Publish to production | Make live for users |
245
+ | `lua push all --force` | Batch push all | CI/CD pipelines |
258
246
 
259
247
  ---
260
248
 
261
- ### ProductsTool.ts
262
- **What it does:** Complete product management (6 tools)
263
-
264
- **Learn from this:**
265
- - Full CRUD operations
266
- - Search functionality
267
- - Pagination handling
268
- - Platform API usage
249
+ ## 🔒 Environment Variables
269
250
 
270
- **Tools included:**
271
- - `search_products` - Search catalog
272
- - `get_all_products` - List with pagination
273
- - `create_product` - Add new products
274
- - `update_product` - Modify existing
275
- - `get_product_by_id` - Get specific product
276
- - `delete_product` - Remove products
251
+ Store sensitive data in `.env`:
277
252
 
278
- **Use it for:**
279
- - E-commerce catalogs
280
- - Inventory management
281
- - Product recommendations
282
-
283
- ---
253
+ ```bash
254
+ # Copy from example
255
+ cp env.example .env
284
256
 
285
- ### BasketTool.ts
286
- **What it does:** Shopping cart operations (9 tools)
257
+ # Add your API keys
258
+ OPENAI_API_KEY=sk-...
259
+ STRIPE_SECRET_KEY=sk_live_...
260
+ PINECONE_API_KEY=...
287
261
 
288
- **Learn from this:**
289
- - Multi-step workflows
290
- - State management
291
- - Complex business logic
262
+ # Optional: For CI/CD
263
+ LUA_API_KEY=your-lua-api-key
264
+ ```
292
265
 
293
- **Tools included:**
294
- - `create_basket` - Start shopping
295
- - `get_baskets` - List carts
296
- - `add_to_basket` - Add items
297
- - `remove_from_basket` - Remove items
298
- - `clear_basket` - Empty cart
299
- - `update_basket_status` - Change status
300
- - `update_basket_metadata` - Add metadata
301
- - `checkout_basket` - Convert to order
302
- - `get_basket_by_id` - Get specific basket
303
-
304
- **Use it for:**
305
- - Shopping carts
306
- - Temporary storage
307
- - Multi-item collections
266
+ **Priority:**
267
+ 1. System keychain (most secure)
268
+ 2. `LUA_API_KEY` environment variable
269
+ 3. `.env` file
308
270
 
309
271
  ---
310
272
 
311
- ### OrderTool.ts
312
- **What it does:** Order creation and tracking (4 tools)
313
-
314
- **Learn from this:**
315
- - Order fulfillment flows
316
- - Status management
317
- - Basket-to-order conversion
273
+ ## 🎨 Customization Guide
318
274
 
319
- **Use it for:**
320
- - Order processing
321
- - Purchase completion
322
- - Order tracking
275
+ ### 1. Update Agent Identity
323
276
 
324
- ---
277
+ Edit `src/index.ts`:
325
278
 
326
- ### CustomDataTool.ts
327
- **What it does:** Movie database with vector search (6 tools)
328
-
329
- **Learn from this:**
330
- - **Vector search** - Semantic similarity search
331
- - Custom data collections
332
- - Search indexing
333
- - CRUD on custom schemas
334
-
335
- **Tools included:**
336
- - `create_movie` - Add movie with search indexing
337
- - `get_movies` - List all movies
338
- - `get_movie_by_id` - Get specific movie
339
- - `update_movie` - Modify movie data
340
- - `search_movies` - **Semantic search** (find similar)
341
- - `delete_movie` - Remove movie
342
-
343
- **Use it for:**
344
- - Knowledge bases
345
- - Document search
346
- - FAQs
347
- - Any searchable content
348
- - Recommendation systems
349
-
350
- **Vector Search Example:**
351
279
  ```typescript
352
- // Create with search text
353
- await Data.create('movies', {
354
- title: 'Inception',
355
- director: 'Christopher Nolan'
356
- }, 'Inception Christopher Nolan sci-fi thriller dreams');
357
-
358
- // Search semantically
359
- const results = await Data.search('movies', 'mind-bending thriller', 10, 0.7);
360
- // Returns: Inception with high similarity score!
280
+ export const agent = new LuaAgent({
281
+ name: 'my-customer-support-bot', // ✏️ Change this
282
+
283
+ persona: `You are Sarah, a friendly customer support agent...`, // ✏️ Customize
284
+
285
+ welcomeMessage: 'Hi! I\'m Sarah. How can I help you today?', // ✏️ Personalize
286
+
287
+ // ...
288
+ });
361
289
  ```
362
290
 
363
- ---
291
+ ### 2. Add Your Own Tool
364
292
 
365
- ### PaymentTool.ts
366
- **What it does:** Creates payment links (Stripe example)
293
+ Create `src/skills/tools/MyTool.ts`:
367
294
 
368
- **Learn from this:**
369
- - Environment variables for API keys
370
- - External service integration
371
- - Payment processing
295
+ ```typescript
296
+ import { LuaTool } from "lua-cli/skill";
297
+ import { z } from "zod";
372
298
 
373
- **Use it for:**
374
- - Payment collection
375
- - Checkout flows
376
- - Subscription management
299
+ export default class MyTool implements LuaTool {
300
+ name = "my_tool";
301
+ description = "What this tool does";
302
+
303
+ inputSchema = z.object({
304
+ param: z.string()
305
+ });
377
306
 
378
- ---
307
+ async execute(input: z.infer<typeof this.inputSchema>) {
308
+ // Your logic here
309
+ return { result: "success" };
310
+ }
311
+ }
312
+ ```
379
313
 
380
- ### CreatePostTool.ts
381
- **What it does:** Simple example tool
314
+ Add to a skill in `src/index.ts`:
382
315
 
383
- **Learn from this:**
384
- - Basic tool structure
385
- - Minimal implementation
386
- - Good starting point
316
+ ```typescript
317
+ import MyTool from './skills/tools/MyTool';
387
318
 
388
- ---
319
+ const mySkill = new LuaSkill({
320
+ name: 'my-skill',
321
+ description: 'My custom skill',
322
+ context: 'Use these tools for...',
323
+ tools: [new MyTool()]
324
+ });
389
325
 
390
- ## 🎨 Customization Guide
326
+ export const agent = new LuaAgent({
327
+ // ...
328
+ skills: [...existingSkills, mySkill],
329
+ });
330
+ ```
391
331
 
392
- ### Scenario 1: Keep Only What You Need
332
+ ### 3. Configure Webhooks
393
333
 
394
- **If you only need products:**
334
+ Uncomment in `src/index.ts`:
395
335
 
396
- 1. **Update `src/index.ts`:**
397
336
  ```typescript
398
- import { LuaSkill } from "lua-cli";
399
- import { SearchProductsTool, CreateProductTool } from "./tools/ProductsTool";
400
-
401
- const productSkill = new LuaSkill({
402
- name: "product-catalog-skill",
403
- version: "1.0.0",
404
- description: "Product search and management",
405
- context: "Use search_products to find items. Use create_product to add new items.",
406
- tools: [
407
- new SearchProductsTool(),
408
- new CreateProductTool()
409
- ]
337
+ import paymentWebhook from './webhooks/PaymentWebhook';
338
+
339
+ export const agent = new LuaAgent({
340
+ // ...
341
+ webhooks: [paymentWebhook], // ✅ Enabled
410
342
  });
411
343
  ```
412
344
 
413
- 2. **Delete unused tool files:**
414
- ```bash
415
- rm src/tools/BasketTool.ts
416
- rm src/tools/OrderTool.ts
417
- rm src/tools/CustomDataTool.ts
418
- # Keep only ProductsTool.ts
345
+ Get your webhook URL after deployment:
419
346
  ```
420
-
421
- 3. **Test:**
422
- ```bash
423
- lua test
347
+ https://webhook.heylua.ai/{agentId}/{webhookId}
424
348
  ```
425
349
 
426
- ---
427
-
428
- ### Scenario 2: Build a Restaurant Skill
429
-
430
- 1. **Rename tools to match your domain:**
350
+ ### 4. Schedule Jobs
431
351
 
432
- Rename `CustomDataTool.ts` `MenuTool.ts`
352
+ Uncomment in `src/index.ts`:
433
353
 
434
- 2. **Update tool names and descriptions:**
435
354
  ```typescript
436
- export class CreateMenuItemTool implements LuaTool {
437
- name = "create_menu_item";
438
- description = "Add a new item to the restaurant menu";
439
-
440
- inputSchema = z.object({
441
- name: z.string(),
442
- category: z.enum(['appetizers', 'mains', 'desserts', 'drinks']),
443
- price: z.number(),
444
- description: z.string()
445
- });
446
-
447
- async execute(input: any) {
448
- const searchText = `${input.name} ${input.category} ${input.description}`;
449
- return await Data.create('menu_items', input, searchText);
450
- }
451
- }
452
- ```
355
+ import dailyCleanupJob from './jobs/DailyCleanupJob';
453
356
 
454
- 3. **Update skill context:**
455
- ```typescript
456
- const restaurantSkill = new LuaSkill({
457
- description: "Restaurant assistant for menu, orders, and reservations",
458
- context: `
459
- Help customers interact with the restaurant.
460
-
461
- - Use show_menu when asked about food or drinks
462
- - Use create_order when taking orders (confirm items first)
463
- - Use make_reservation for table bookings
464
-
465
- Always mention daily specials.
466
- Confirm order details before submitting.
467
- `,
468
- tools: [new ShowMenuTool(), new CreateOrderTool()]
357
+ export const agent = new LuaAgent({
358
+ // ...
359
+ jobs: [dailyCleanupJob], // Enabled
469
360
  });
470
361
  ```
471
362
 
472
363
  ---
473
364
 
474
- ### Scenario 3: Build a CRM Skill
365
+ ## 📚 Documentation
475
366
 
476
- 1. **Create customer management tools:**
367
+ ### Comprehensive Guides
368
+ - **[Quick Start Guide](QUICKSTART.md)** - Step-by-step tutorial
369
+ - **[Example Skills](src/skills/)** - Browse working examples
370
+ - **[Example Webhooks](src/webhooks/)** - Webhook patterns
371
+ - **[Example Jobs](src/jobs/)** - Job scheduling examples
477
372
 
478
- Create `src/tools/CustomerTool.ts`:
479
- ```typescript
480
- import { LuaTool, Data } from "lua-cli";
481
- import { z } from "zod";
482
-
483
- export class CreateCustomerTool implements LuaTool {
484
- name = "create_customer";
485
- description = "Add a new customer to CRM";
486
-
487
- inputSchema = z.object({
488
- name: z.string(),
489
- email: z.string().email(),
490
- company: z.string().optional(),
491
- phone: z.string().optional()
492
- });
373
+ ### Official Documentation
374
+ - **Lua Docs:** https://docs.heylua.ai
375
+ - **CLI Reference:** https://github.com/heylua/lua-cli
376
+ - **Community:** https://community.heylua.ai
493
377
 
494
- async execute(input: any) {
495
- const searchText = `${input.name} ${input.email} ${input.company || ''}`;
496
-
497
- const customer = await Data.create('customers', {
498
- ...input,
499
- status: 'active',
500
- createdAt: new Date().toISOString()
501
- }, searchText);
502
-
503
- return {
504
- customerId: customer.id,
505
- message: `Customer ${input.name} added to CRM`
506
- };
507
- }
508
- }
378
+ ---
509
379
 
510
- export class SearchCustomersTool implements LuaTool {
511
- name = "search_customers";
512
- description = "Search customers by name, email, or company";
513
- inputSchema = z.object({ query: z.string() });
514
-
515
- async execute(input: any) {
516
- const results = await Data.search('customers', input.query, 10, 0.7);
517
-
518
- return {
519
- customers: results.data.map(entry => ({
520
- id: entry.id,
521
- ...entry.data,
522
- relevance: entry.score
523
- }))
524
- };
525
- }
526
- }
527
- ```
380
+ ## 🧪 Testing Strategy
528
381
 
529
- 2. **Create interaction tracking:**
382
+ ### Local Testing (Recommended)
530
383
 
531
- ```typescript
532
- export class LogInteractionTool implements LuaTool {
533
- name = "log_interaction";
534
- description = "Log customer interaction";
535
-
536
- inputSchema = z.object({
537
- customerId: z.string(),
538
- type: z.enum(['call', 'email', 'meeting']),
539
- notes: z.string()
540
- });
384
+ ```bash
385
+ # Test individual tools
386
+ lua test
541
387
 
542
- async execute(input: any) {
543
- await Data.create('interactions', {
544
- customerId: input.customerId,
545
- type: input.type,
546
- notes: input.notes,
547
- timestamp: new Date().toISOString()
548
- }, `${input.type} ${input.notes}`);
549
-
550
- return { success: true };
551
- }
552
- }
388
+ # Interactive chat testing
389
+ lua chat
390
+ # Select: Sandbox
553
391
  ```
554
392
 
555
- ---
393
+ **Why sandbox?**
394
+ - ✅ Uses your local code (not deployed)
395
+ - ✅ Safe for experimentation
396
+ - ✅ Instant feedback
397
+ - ✅ No production impact
556
398
 
557
- ## 🔧 Development Commands
399
+ ### Production Testing
558
400
 
559
401
  ```bash
560
- # Install dependencies
561
- npm install
402
+ lua chat
403
+ # Select: Production
404
+ ```
562
405
 
563
- # Test tools interactively
564
- npm run test
565
- # or
566
- lua test
406
+ **When to use:**
407
+ - After deploying
408
+ - ✅ Validate production behavior
409
+ - ✅ Test with real data
567
410
 
568
- # Start development mode
569
- npm run dev
570
- # or
571
- lua dev
411
+ ---
572
412
 
573
- # Compile skill
574
- npm run compile
575
- # or
576
- lua compile
413
+ ## 🚀 Deployment Options
577
414
 
578
- # Push to server
579
- npm run push
580
- # or
581
- lua push
415
+ ### Option 1: Interactive (Recommended for First Time)
582
416
 
583
- # Deploy to production
584
- lua deploy
417
+ ```bash
418
+ lua push
419
+ # Select component type
420
+ # Confirm version
421
+ # Choose whether to deploy
585
422
  ```
586
423
 
587
- ---
588
-
589
- ## 📝 Configuration Files
424
+ **Best for:**
425
+ - Learning the deployment process
426
+ - Reviewing changes before deploying
427
+ - Fine-grained control
590
428
 
591
- ### `lua.skill.yaml`
429
+ ### Option 2: Batch Deployment (CI/CD)
592
430
 
593
- Auto-managed configuration file. Contains:
594
- - Agent ID and organization ID
595
- - Skill IDs (auto-created during compilation)
596
- - Optional environment variables
597
-
598
- ```yaml
599
- agent:
600
- agentId: agent_abc123
601
- orgId: org_xyz789
602
-
603
- skills:
604
- - name: my-skill
605
- version: 1.0.0
606
- skillId: skill_xyz789 # Auto-created
431
+ ```bash
432
+ lua push all --force --auto-deploy
607
433
  ```
608
434
 
609
- **Don't manually edit `skillId`** - it's auto-managed!
435
+ **What happens:**
436
+ 1. Compiles all code
437
+ 2. Auto-bumps patch versions
438
+ 3. Pushes all skills, webhooks, jobs, processors
439
+ 4. Deploys everything to production
440
+
441
+ **Best for:**
442
+ - CI/CD pipelines
443
+ - Batch updates
444
+ - Production deployments
610
445
 
611
446
  ---
612
447
 
613
- ### `.env` File
448
+ ## 💡 Pro Tips
614
449
 
615
- Create `.env` for environment variables:
450
+ ### Development
451
+ - ✅ Use `lua test` frequently during development
452
+ - ✅ Test in sandbox before deploying
453
+ - ✅ Keep tools small and focused (single responsibility)
454
+ - ✅ Use TypeScript for better error catching
616
455
 
617
- ```bash
618
- # External API Keys
619
- STRIPE_API_KEY=sk_test_abc123
620
- SENDGRID_API_KEY=SG.xyz789
621
- OPENAI_API_KEY=sk-abc123
622
-
623
- # Configuration
624
- API_BASE_URL=https://api.example.com
625
- ENABLE_DEBUG=false
626
- ```
456
+ ### Tools
457
+ - Validate all inputs with Zod schemas
458
+ - ✅ Return structured objects (not just strings)
459
+ - ✅ Handle errors gracefully
460
+ - ✅ Use descriptive names and descriptions (the AI reads these!)
627
461
 
628
- **Remember:** Add `.env` to `.gitignore`!
462
+ ### Jobs
463
+ - ✅ Always pass data via `metadata` field
464
+ - ✅ Make execute functions self-contained
465
+ - ✅ Use appropriate schedule types (once, cron, interval)
466
+ - ✅ Test job logic in regular tools first
629
467
 
630
- ---
468
+ ### Webhooks
469
+ - ✅ Validate signatures in production
470
+ - ✅ Return proper HTTP status codes
471
+ - ✅ Handle retries and idempotency
472
+ - ✅ Test with tools like Postman first
631
473
 
632
- ### `package.json`
633
-
634
- Contains your dependencies and scripts:
635
-
636
- ```json
637
- {
638
- "name": "your-skill-name",
639
- "version": "1.0.0",
640
- "scripts": {
641
- "test": "lua test",
642
- "dev": "lua dev",
643
- "compile": "lua compile",
644
- "push": "lua push"
645
- },
646
- "dependencies": {
647
- "lua-cli": "^2.0.0",
648
- "zod": "^3.0.0"
649
- }
650
- }
651
- ```
474
+ ### Agent Persona
475
+ - ✅ Be specific about personality and tone
476
+ - Define what the agent can/cannot do
477
+ - ✅ Give examples of good responses
478
+ - ✅ Update based on user feedback
652
479
 
653
480
  ---
654
481
 
655
- ## 🎯 Next Steps
482
+ ## 🔄 Keeping Your Agent Updated
656
483
 
657
- ### 1. Explore the Examples
484
+ ### When You Make Changes
658
485
 
659
- **Try each tool:**
660
486
  ```bash
487
+ # 1. Test your changes
661
488
  lua test
662
- ```
663
489
 
664
- - Test `get_weather` - See external API calls
665
- - Test `search_products` - See platform API usage
666
- - Test `search_movies` - See vector search
667
- - Test `create_basket` → `add_to_basket` → `checkout_basket` - See workflows
490
+ # 2. Compile
491
+ lua compile
668
492
 
669
- ---
493
+ # 3. Push new version
494
+ lua push
670
495
 
671
- ### 2. Understand the Code
496
+ # 4. Deploy when ready
497
+ lua deploy
498
+ ```
672
499
 
673
- **Read the tool files** in `src/tools/`:
674
- - Start with simple ones (`GetWeatherTool.ts`, `CreatePostTool.ts`)
675
- - Then explore complex ones (`BasketTool.ts`, `ProductsTool.ts`)
676
- - Study vector search (`CustomDataTool.ts`)
500
+ ### Sync Your Configuration
677
501
 
678
- **Key files to understand:**
679
- - `src/index.ts` - How skills are structured
680
- - `src/tools/ProductsTool.ts` - Complete CRUD pattern
681
- - `src/tools/CustomDataTool.ts` - Vector search pattern
682
- - `src/tools/BasketTool.ts` - Multi-step workflow pattern
502
+ The CLI automatically keeps your `lua.skill.yaml` and `LuaAgent` in sync:
503
+
504
+ - **Run `lua init`** Syncs agent name, persona, welcomeMessage to both files
505
+ - **Run `lua compile`** Syncs LuaAgent changes back to YAML
506
+ - **Manual edit YAML** → Re-run `lua compile` to rebuild
683
507
 
684
508
  ---
685
509
 
686
- ### 3. Make It Yours
510
+ ## 🎨 Example Use Cases
687
511
 
688
- **Choose your approach:**
512
+ ### Customer Support Agent
513
+ ```typescript
514
+ persona: `You are Alex, a patient and knowledgeable customer support agent.
515
+ You help customers with orders, returns, and product questions.
516
+ Always be empathetic and solution-oriented.`
689
517
 
690
- #### A. Modify Examples
691
- Keep examples, change them to your domain:
692
- - Movies → Your data type
693
- - Products → Your catalog
694
- - Weather → Your external API
518
+ skills: [productSkill, orderSkill, basketSkill]
519
+ ```
695
520
 
696
- #### B. Start Fresh
697
- Delete examples, create new tools:
698
- ```bash
699
- rm src/tools/*.ts
700
- touch src/tools/MyFirstTool.ts
521
+ ### E-commerce Assistant
522
+ ```typescript
523
+ persona: `You are Sophia, an enthusiastic shopping assistant.
524
+ You help customers find products, make recommendations, and complete purchases.
525
+ Use a friendly, upbeat tone and be proactive with suggestions.`
526
+
527
+ skills: [productSkill, basketSkill, paymentSkill]
701
528
  ```
702
529
 
703
- #### C. Mix and Match
704
- Keep useful examples, add custom tools:
705
- - Keep: `UserDataTool.ts` (always useful)
706
- - Keep: `CustomDataTool.ts` (for knowledge base)
707
- - Remove: `BasketTool.ts` (if not e-commerce)
708
- - Add: Your custom tools
530
+ ### Data Analysis Agent
531
+ ```typescript
532
+ persona: `You are DataBot, an analytical AI assistant.
533
+ You help users query data, generate reports, and visualize insights.
534
+ Be precise, data-driven, and thorough in your analysis.`
535
+
536
+ skills: [customDataSkill, analyticsSkill, reportSkill]
537
+ ```
709
538
 
710
539
  ---
711
540
 
712
- ### 4. Deploy
541
+ ## 🔐 Security Best Practices
713
542
 
714
- ```bash
715
- # Test thoroughly
716
- lua test
717
- lua dev
543
+ ### API Keys
544
+ - Never commit `.env` file to version control
545
+ - ✅ Use `.env.example` as a template
546
+ - ✅ Rotate API keys regularly
547
+ - ✅ Use environment-specific keys (sandbox vs production)
718
548
 
719
- # Push to server
720
- lua push
549
+ ### Webhooks
550
+ - ✅ Validate webhook signatures in production
551
+ - ✅ Use HTTPS endpoints only
552
+ - ✅ Rate limit webhook handlers
553
+ - ✅ Log all webhook events
721
554
 
722
- # Deploy to production
723
- lua deploy
724
- ```
555
+ ### User Data
556
+ - ✅ Only store necessary data
557
+ - ✅ Encrypt sensitive information
558
+ - ✅ Respect user privacy preferences
559
+ - ✅ Implement data deletion on request
725
560
 
726
561
  ---
727
562
 
728
- ## 📚 Documentation
729
-
730
- ### In This Project
731
- - **README.md** - This file (project overview)
732
- - **QUICKSTART.md** - 5-minute start guide
733
- - **TOOL_EXAMPLES.md** - Detailed tool explanations
563
+ ## 🐛 Troubleshooting
734
564
 
735
- ### Lua CLI Documentation
736
- - **Getting Started** - Complete tutorial
737
- - **API Reference** - All platform APIs
738
- - **CLI Reference** - All commands
739
- - **Template Guide** - This template explained
565
+ ### Common Issues
740
566
 
741
- **Access via:**
567
+ **"Tool not found by agent"**
742
568
  ```bash
743
- # In your node_modules
744
- ls node_modules/lua-cli/*.md
745
-
746
- # Or online
747
- https://docs.heylua.ai
569
+ # Make sure tool is in a skill, skill is in LuaAgent
570
+ lua compile # Rebuilds everything
748
571
  ```
749
572
 
750
- ---
573
+ **"Cannot find module '../services/ApiService'"**
574
+ ```bash
575
+ # Make sure all dependencies are installed
576
+ npm install
577
+ ```
751
578
 
752
- ## 💡 Tips & Tricks
579
+ **"Job execute function: ReferenceError: input is not defined"**
580
+ ```typescript
581
+ // ❌ Wrong: Accessing parent scope
582
+ execute: async (job) => {
583
+ const message = input.message; // Error!
584
+ }
753
585
 
754
- ### Tip 1: Start with Dev Mode
586
+ // Correct: Use metadata
587
+ metadata: { message: input.message },
588
+ execute: async (job) => {
589
+ const message = job.metadata.message; // Works!
590
+ }
591
+ ```
755
592
 
593
+ **"Version not found when deploying"**
756
594
  ```bash
757
- lua dev
595
+ # Server needs time to process. Wait 10 seconds, then:
596
+ lua deploy
758
597
  ```
759
598
 
760
- **Why?**
761
- - Instant feedback
762
- - Chat testing
763
- - Live reload
764
- - See what the AI actually does
765
-
766
599
  ---
767
600
 
768
- ### Tip 2: Use Vector Search
601
+ ## 📈 Scaling Your Agent
769
602
 
770
- For any searchable content:
771
- ```typescript
772
- // When creating
773
- await Data.create('items', data, searchableText);
603
+ ### Add More Skills
774
604
 
775
- // When searching
776
- const results = await Data.search('items', query, 10, 0.7);
777
- ```
605
+ As your agent grows, organize tools into skills:
778
606
 
779
- **Great for:**
780
- - FAQs
781
- - Documentation
782
- - Product descriptions
783
- - Customer notes
784
-
785
- ---
607
+ ```typescript
608
+ // src/skills/analytics.skill.ts
609
+ export const analyticsSkill = new LuaSkill({
610
+ name: 'analytics-skill',
611
+ description: 'Data analytics and reporting',
612
+ context: 'Use these tools for data analysis',
613
+ tools: [
614
+ new GenerateReportTool(),
615
+ new ExportDataTool(),
616
+ new VisualizeTool()
617
+ ]
618
+ });
619
+ ```
786
620
 
787
- ### Tip 3: Write Good Context
621
+ ### Add Background Processing
788
622
 
789
- The `context` field is critical - it guides the AI:
623
+ Use jobs for heavy or scheduled work:
790
624
 
791
- **✅ Good:**
792
625
  ```typescript
793
- context: `
794
- This skill helps users find and purchase products.
795
-
796
- - Use search_products when users describe what they want
797
- - Use create_basket to start a new shopping session
798
- - Use add_to_basket when they want to buy something
799
- - Use checkout_basket to complete the purchase
800
-
801
- Always confirm items and total before checkout.
802
- Mention shipping options during checkout.
803
- `
626
+ // Instead of making users wait
627
+ // Create a job that processes in background
628
+ const job = await Jobs.create({
629
+ name: 'process-large-file',
630
+ metadata: { fileId: input.fileId },
631
+ schedule: { type: "once", executeAt: new Date() },
632
+ execute: async (job) => {
633
+ // Process file
634
+ // Notify user when done
635
+ }
636
+ });
804
637
  ```
805
638
 
806
- **❌ Bad:**
639
+ ### Add External Integrations
640
+
641
+ Use webhooks to receive events:
642
+
807
643
  ```typescript
808
- context: "Product and shopping tools"
644
+ // Receive events from Stripe, Shopify, etc.
645
+ export default new LuaWebhook({
646
+ name: "shopify-order",
647
+ execute: async ({ body }) => {
648
+ // Process Shopify order
649
+ // Update your system
650
+ // Notify customer
651
+ }
652
+ });
809
653
  ```
810
654
 
811
655
  ---
812
656
 
813
- ### Tip 4: Test with Real Scenarios
657
+ ## 🔧 Advanced Configuration
814
658
 
815
- Don't just test with perfect inputs:
659
+ ### Multiple Environments
816
660
 
817
661
  ```bash
818
- lua dev
662
+ # Sandbox (testing)
663
+ lua chat # Select Sandbox
664
+ lua env sandbox
665
+
666
+ # Production (live users)
667
+ lua chat # Select Production
668
+ lua env production
819
669
  ```
820
670
 
821
- **Try:**
822
- - ✅ "What's the weather?" (missing city - should prompt)
823
- - ✅ "Add laptop to cart" (need basket ID - should create)
824
- - ✅ "XYZ" (nonsense - should handle gracefully)
671
+ ### Skill Overrides
825
672
 
826
- ---
673
+ Test specific skill versions without deploying:
827
674
 
828
- ### Tip 5: Use Environment Variables
675
+ ```typescript
676
+ // In sandbox mode, test development versions
677
+ // Production uses deployed versions
678
+ ```
679
+
680
+ ### Processor Chains
829
681
 
830
- **Never hardcode secrets:**
682
+ Process messages in order:
831
683
 
832
684
  ```typescript
833
- // ❌ Bad
834
- const apiKey = 'sk_abc123';
685
+ preProcessors: [
686
+ profanityFilter, // 1. Clean input
687
+ intentClassifier, // 2. Detect intent
688
+ messageRouter // 3. Route to handler
689
+ ]
835
690
 
836
- // ✅ Good
837
- import { env } from 'lua-cli';
838
- const apiKey = env('STRIPE_API_KEY');
839
- ```
840
-
841
- Create `.env`:
842
- ```bash
843
- STRIPE_API_KEY=your_key_here
691
+ postProcessors: [
692
+ responseFormatter, // 1. Format output
693
+ addDisclaimer, // 2. Add legal text
694
+ translateResponse // 3. Translate if needed
695
+ ]
844
696
  ```
845
697
 
846
698
  ---
847
699
 
848
- ## 🎨 Customization Recipes
700
+ ## 📊 Monitoring & Management
849
701
 
850
- ### Recipe 1: Simple Weather Skill
702
+ ### View Production Status
851
703
 
852
- ```typescript
853
- // src/index.ts
854
- import { LuaSkill } from "lua-cli";
855
- import GetWeatherTool from "./tools/GetWeatherTool";
856
-
857
- const weatherSkill = new LuaSkill({
858
- name: "weather-skill",
859
- version: "1.0.0",
860
- description: "Provides weather information worldwide",
861
- context: "Use get_weather when users ask about weather or temperature. Always include the city name.",
862
- tools: [new GetWeatherTool()]
863
- });
704
+ ```bash
705
+ lua production
864
706
  ```
865
707
 
866
- **Deploy:**
708
+ Shows:
709
+ - Active skills and versions
710
+ - Webhook URLs
711
+ - Scheduled jobs
712
+ - Environment variables
713
+
714
+ ### View Logs
715
+
867
716
  ```bash
868
- lua test # Test it
869
- lua push # Upload
870
- lua deploy # Go live
717
+ lua logs
871
718
  ```
872
719
 
873
- ---
720
+ See:
721
+ - Agent conversations
722
+ - Tool executions
723
+ - Errors and warnings
724
+ - Performance metrics
874
725
 
875
- ### Recipe 2: Knowledge Base Skill
726
+ ### Manage Skills
876
727
 
877
- Use CustomDataTool.ts as template:
728
+ ```bash
729
+ # List all skills
730
+ lua skills
878
731
 
879
- 1. Rename collections: `movies` → `articles`
880
- 2. Update fields: title, director → title, content, category
881
- 3. Update descriptions to match your domain
882
- 4. Update skill context
732
+ # Push specific skill
733
+ lua push skill
883
734
 
884
- **Result:** Searchable knowledge base!
735
+ # Deploy specific version
736
+ lua deploy
737
+ ```
885
738
 
886
739
  ---
887
740
 
888
- ### Recipe 3: E-commerce Skill
741
+ ## 🌐 CI/CD Integration
889
742
 
890
- Keep: `ProductsTool.ts`, `BasketTool.ts`, `OrderTool.ts`
743
+ ### GitHub Actions Example
891
744
 
892
- Remove: Everything else
745
+ ```yaml
746
+ # .github/workflows/deploy.yml
747
+ name: Deploy Lua Agent
748
+
749
+ on:
750
+ push:
751
+ branches: [main]
752
+
753
+ jobs:
754
+ deploy:
755
+ runs-on: ubuntu-latest
756
+ steps:
757
+ - uses: actions/checkout@v3
758
+
759
+ - name: Setup Node.js
760
+ uses: actions/setup-node@v3
761
+ with:
762
+ node-version: '20'
763
+
764
+ - name: Install dependencies
765
+ run: npm install
766
+
767
+ - name: Install Lua CLI
768
+ run: npm install -g lua-cli@alpha
769
+
770
+ - name: Deploy to production
771
+ run: lua push all --force --auto-deploy
772
+ env:
773
+ LUA_API_KEY: ${{ secrets.LUA_API_KEY }}
774
+ ```
775
+
776
+ ### GitLab CI Example
893
777
 
894
- **Result:** Complete shopping experience!
778
+ ```yaml
779
+ # .gitlab-ci.yml
780
+ deploy:
781
+ stage: deploy
782
+ image: node:20
783
+ script:
784
+ - npm install
785
+ - npm install -g lua-cli@alpha
786
+ - lua push all --force --auto-deploy
787
+ only:
788
+ - main
789
+ variables:
790
+ LUA_API_KEY: $LUA_API_KEY
791
+ ```
895
792
 
896
793
  ---
897
794
 
898
- ## 🔍 Understanding Multi-Skill Projects
795
+ ## 🤝 Contributing
899
796
 
900
- This template has **7 skills** in one project:
797
+ ### Adding Examples
901
798
 
902
- **Why multiple skills?**
903
- - Different domains (products vs orders)
904
- - Different deployment schedules
905
- - Logical organization
906
- - Easier to manage
799
+ Have a great tool example? Add it to the template:
907
800
 
908
- **How it works:**
909
- - Each skill gets its own `skillId` in `lua.skill.yaml`
910
- - All skills deploy together with `lua push`
911
- - All skills available to your agent
912
- - AI chooses right skill automatically
801
+ 1. Create the tool in `src/skills/tools/`
802
+ 2. Add it to a skill
803
+ 3. Test thoroughly
804
+ 4. Document the use case
913
805
 
914
- **You can:**
915
- - Keep all 7 (if relevant)
916
- - Merge into 1 (simpler)
917
- - Create your own grouping
806
+ ### Reporting Issues
918
807
 
919
- ---
808
+ Found a bug or have a suggestion?
920
809
 
921
- ## 📊 Tool Inventory
810
+ - GitHub Issues: https://github.com/heylua/lua-cli/issues
811
+ - Email: support@heylua.ai
922
812
 
923
- ### Included Tools (30 total)
813
+ ---
924
814
 
925
- | Category | Count | Examples |
926
- |----------|-------|----------|
927
- | **Weather** | 1 | get_weather |
928
- | **User Data** | 2 | get_user_data, update_user_data |
929
- | **Products** | 6 | search, create, update, get, delete, get_by_id |
930
- | **Baskets** | 9 | create, add_item, remove, clear, checkout, etc. |
931
- | **Orders** | 4 | create, update_status, get, get_by_id |
932
- | **Custom Data** | 6 | create, search, update, delete (movies example) |
933
- | **Payment** | 1 | create_payment_link |
934
- | **Posts** | 1 | create_post |
815
+ ## 📝 Important Notes
935
816
 
936
- **Total: 30 working examples** covering all major use cases!
817
+ ### About Jobs and Closures
937
818
 
938
- ---
819
+ ⚠️ **Job execute functions must be self-contained**
939
820
 
940
- ## 🚨 Common Mistakes to Avoid
941
-
942
- ### ❌ Mistake 1: Hardcoding API Keys
943
821
  ```typescript
944
- const apiKey = 'sk_abc123'; // DON'T DO THIS
945
- ```
822
+ // This will NOT work:
823
+ async execute(input: any) {
824
+ const userMessage = input.message;
825
+
826
+ await Jobs.create({
827
+ execute: async (job) => {
828
+ // userMessage is undefined here!
829
+ await user.send(userMessage);
830
+ }
831
+ });
832
+ }
946
833
 
947
- **Fix:** Use environment variables
948
- ```typescript
949
- import { env } from 'lua-cli';
950
- const apiKey = env('API_KEY');
834
+ // This WILL work:
835
+ async execute(input: any) {
836
+ await Jobs.create({
837
+ metadata: { message: input.message }, // Pass via metadata
838
+ execute: async (job) => {
839
+ // Access from metadata
840
+ await job.user().send(job.metadata.message);
841
+ }
842
+ });
843
+ }
951
844
  ```
952
845
 
953
- ---
846
+ **Why?** Jobs are serialized and executed in a sandbox. They can't access parent scope variables.
954
847
 
955
- ### Mistake 2: Unclear Tool Names
956
- ```typescript
957
- name = "tool1" // Unclear
958
- name = "do_stuff" // Too generic
959
- ```
848
+ ### About Bundling
960
849
 
961
- **Fix:** Be specific
962
- ```typescript
963
- name = "search_products"
964
- name = "create_order"
965
- name = "get_user_profile"
966
- ```
850
+ The CLI automatically:
851
+ - ✅ Bundles all tool code and dependencies
852
+ - Excludes lua-cli APIs (available in sandbox)
853
+ - Compresses code for transmission
854
+ - Handles imports and dependencies
855
+
856
+ You don't need to worry about bundling - it just works!
967
857
 
968
858
  ---
969
859
 
970
- ### Mistake 3: Weak Descriptions
971
- ```typescript
972
- description = "Gets data" // Too vague
973
- ```
860
+ ## 🎯 What's Next?
974
861
 
975
- **Fix:** Be descriptive
976
- ```typescript
977
- description = "Searches product catalog by name, category, or description"
978
- ```
862
+ ### Immediate Actions
863
+ 1. ✅ Test the example tools: `lua test`
864
+ 2. Chat with your agent: `lua chat` (select Sandbox)
865
+ 3. ✅ Read the [Quick Start Guide](QUICKSTART.md)
866
+ 4. ✅ Customize the agent persona in `src/index.ts`
979
867
 
980
- ---
868
+ ### Short Term
869
+ 1. ✅ Create your first custom tool
870
+ 2. ✅ Deploy to production: `lua push`
871
+ 3. ✅ Test in production: `lua chat` (select Production)
981
872
 
982
- ### Mistake 4: Missing Error Handling
983
- ```typescript
984
- async execute(input: any) {
985
- const result = await api.call(input);
986
- return result; // What if it fails?
987
- }
988
- ```
989
-
990
- ✅ **Fix:** Handle errors
991
- ```typescript
992
- async execute(input: any) {
993
- try {
994
- const result = await api.call(input);
995
- if (!result.success) {
996
- throw new Error(result.error || 'API call failed');
997
- }
998
- return result.data;
999
- } catch (error) {
1000
- throw new Error(`Failed to fetch data: ${error.message}`);
1001
- }
1002
- }
1003
- ```
873
+ ### Long Term
874
+ 1. ✅ Add webhooks for external integrations
875
+ 2. Schedule jobs for automated tasks
876
+ 3. Build advanced tools with AI/external APIs
877
+ 4. Monitor and improve based on user feedback
1004
878
 
1005
879
  ---
1006
880
 
1007
- ## 🎓 Learning Path
881
+ ## 🌟 Example Projects
1008
882
 
1009
- ### Week 1: Learn by Testing
1010
- - Run `lua test` daily
1011
- - Try every example tool
1012
- - Understand inputs and outputs
1013
- - ✅ Read the tool code
883
+ ### Simple Assistant
884
+ - 3-5 basic tools
885
+ - No webhooks or jobs
886
+ - General Q&A and information retrieval
1014
887
 
1015
- ### Week 2: Modify Examples
1016
- - Change descriptions
1017
- - Add new input fields
1018
- - Modify return values
1019
- - Test your changes
888
+ ### E-commerce Bot
889
+ - Product catalog management
890
+ - Shopping cart tools
891
+ - Payment webhooks
892
+ - Abandoned cart jobs
1020
893
 
1021
- ### Week 3: Build Your Own
1022
- - Create 1-2 custom tools
1023
- - Remove unused examples
1024
- - Update skill context
1025
- - Deploy to production
894
+ ### Support Agent
895
+ - Knowledge base search
896
+ - Ticket creation tools
897
+ - Escalation webhooks
898
+ - Daily summary jobs
899
+
900
+ ### Data Platform
901
+ - Custom data tools
902
+ - Report generation
903
+ - Scheduled analytics jobs
904
+ - Webhook integrations
1026
905
 
1027
906
  ---
1028
907
 
1029
- ## 🔗 Resources
908
+ ## 📞 Support & Resources
1030
909
 
1031
- ### Documentation
1032
- - See markdown files in `node_modules/lua-cli/`
1033
- - Visit https://docs.heylua.ai
1034
- - Check CLI help: `lua --help`
910
+ ### Get Help
911
+ - **Documentation:** https://docs.heylua.ai
912
+ - **CLI Reference:** Run `lua --help`
913
+ - **Email Support:** support@heylua.ai
914
+ - **Community:** https://community.heylua.ai
1035
915
 
1036
- ### Examples
1037
- - All tools in `src/tools/` are working examples
1038
- - Copy, modify, learn!
916
+ ### Stay Updated
917
+ ```bash
918
+ # Check your version
919
+ lua --version
1039
920
 
1040
- ### Community
1041
- - GitHub: https://github.com/lua-ai/lua-cli
1042
- - Issues: Report bugs or ask questions
1043
- - Email: support@lua.ai
921
+ # Update to latest alpha
922
+ npm install -g lua-cli@alpha
923
+ ```
1044
924
 
1045
925
  ---
1046
926
 
1047
- ## Checklist Before Deploying
927
+ ## 📄 License
1048
928
 
1049
- - [ ] Removed unused tools and skills
1050
- - [ ] Updated skill names and descriptions
1051
- - [ ] Wrote clear context for AI
1052
- - [ ] Tested all tools with `lua test`
1053
- - [ ] Tested conversationally with `lua dev`
1054
- - [ ] No hardcoded secrets (use `.env`)
1055
- - [ ] Updated version number
1056
- - [ ] Reviewed error messages
1057
- - [ ] Checked tool names (no spaces!)
929
+ This template is provided as part of lua-cli. See the main project license for details.
1058
930
 
1059
931
  ---
1060
932
 
1061
- ## 🎉 You're Ready!
933
+ ## 🎉 Happy Building!
934
+
935
+ You're all set to build amazing AI agents with Lua!
1062
936
 
1063
- This template gives you:
1064
- - **30 working tools** to learn from
1065
- - **All API patterns** demonstrated
1066
- - **Production-ready** structure
1067
- - **Easy to customize** for your needs
937
+ **Remember:**
938
+ 1. Start small - test one tool at a time
939
+ 2. Use sandbox mode liberally
940
+ 3. Read the example code - it's full of patterns
941
+ 4. Deploy often - iterate quickly
1068
942
 
1069
- **Next steps:**
1070
- 1. Test the examples: `lua test`
1071
- 2. Chat with the AI: `lua dev`
1072
- 3. Make it yours: Edit tools and skills
1073
- 4. Deploy: `lua push && lua deploy`
943
+ **Need inspiration?** Check out the example tools in `src/skills/tools/` - they demonstrate:
944
+ - External API calls
945
+ - State management
946
+ - Error handling
947
+ - Complex business logic
948
+ - AI integrations
1074
949
 
1075
- **Go build something amazing!** 🚀
950
+ Build something awesome! 🚀
1076
951
 
1077
952
  ---
1078
953
 
1079
- **Quick Links:**
1080
- - 📘 [Quick Start](QUICKSTART.md) - 5-minute guide
1081
- - 🔧 [Tool Examples](TOOL_EXAMPLES.md) - Detailed tool docs
1082
- - 💻 [CLI Commands](../CLI_REFERENCE.md) - Command reference
1083
- - 📚 [API Docs](../API_REFERENCE.md) - Complete API reference
954
+ *Template version: 3.0.0 | Last updated: October 2025*
1084
955