lua-cli 2.2.8-alpha.1 → 2.3.0-alpha.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.
- package/API_REFERENCE.md +1408 -0
- package/CLI_REFERENCE.md +818 -0
- package/GETTING_STARTED.md +1040 -0
- package/README.md +738 -424
- package/TEMPLATE_GUIDE.md +1398 -0
- package/dist/api/agent.api.service.d.ts +45 -0
- package/dist/api/agent.api.service.js +57 -0
- package/dist/api/auth.api.service.d.ts +48 -0
- package/dist/api/auth.api.service.js +54 -0
- package/dist/api/basket.api.service.d.ts +85 -0
- package/dist/api/basket.api.service.js +164 -0
- package/dist/api/chat.api.service.d.ts +21 -0
- package/dist/api/chat.api.service.js +24 -0
- package/dist/api/credentials.d.ts +24 -0
- package/dist/api/credentials.js +46 -0
- package/dist/api/custom.data.api.service.d.ts +69 -0
- package/dist/api/custom.data.api.service.js +125 -0
- package/dist/api/lazy-instances.d.ts +49 -0
- package/dist/api/lazy-instances.js +95 -0
- package/dist/api/order.api.service.d.ts +53 -0
- package/dist/api/order.api.service.js +95 -0
- package/dist/api/products.api.service.d.ts +66 -0
- package/dist/api/products.api.service.js +112 -0
- package/dist/api/skills.api.service.d.ts +77 -0
- package/dist/api/skills.api.service.js +88 -0
- package/dist/api/tool.api.service.d.ts +52 -0
- package/dist/api/tool.api.service.js +73 -0
- package/dist/api/user.data.api.service.d.ts +33 -0
- package/dist/api/user.data.api.service.js +59 -0
- package/dist/api-exports.d.ts +271 -0
- package/dist/api-exports.js +372 -0
- package/dist/cli/command-definitions.d.ts +30 -0
- package/dist/cli/command-definitions.js +71 -0
- package/dist/commands/agents.d.ts +20 -0
- package/dist/commands/agents.js +24 -2
- package/dist/commands/apiKey.d.ts +23 -0
- package/dist/commands/apiKey.js +23 -0
- package/dist/commands/compile.d.ts +24 -0
- package/dist/commands/compile.js +67 -759
- package/dist/commands/configure.d.ts +24 -0
- package/dist/commands/configure.js +31 -96
- package/dist/commands/deploy.d.ts +31 -19
- package/dist/commands/deploy.js +45 -74
- package/dist/commands/destroy.d.ts +27 -0
- package/dist/commands/destroy.js +27 -1
- package/dist/commands/dev.d.ts +25 -62
- package/dist/commands/dev.js +58 -873
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +98 -260
- package/dist/commands/push.d.ts +24 -21
- package/dist/commands/push.js +39 -92
- package/dist/commands/test.d.ts +26 -0
- package/dist/commands/test.js +41 -188
- package/dist/common/basket.instance.d.ts +78 -0
- package/dist/common/basket.instance.js +132 -0
- package/dist/common/data.entry.instance.d.ts +39 -0
- package/dist/common/data.entry.instance.js +76 -0
- package/dist/common/http.client.d.ts +64 -0
- package/dist/common/http.client.js +133 -0
- package/dist/common/order.instance.d.ts +40 -0
- package/dist/common/order.instance.js +79 -0
- package/dist/common/product.instance.d.ts +33 -0
- package/dist/common/product.instance.js +63 -0
- package/dist/common/product.pagination.instance.d.ts +43 -0
- package/dist/common/product.pagination.instance.js +74 -0
- package/dist/common/product.search.instance.d.ts +22 -0
- package/dist/common/product.search.instance.js +40 -0
- package/dist/common/user.instance.d.ts +41 -0
- package/dist/common/user.instance.js +84 -0
- package/dist/config/auth.constants.d.ts +11 -0
- package/dist/config/auth.constants.js +11 -0
- package/dist/config/compile.constants.d.ts +67 -0
- package/dist/config/compile.constants.js +99 -0
- package/dist/config/constants.d.ts +5 -0
- package/dist/config/constants.js +5 -0
- package/dist/config/dev.constants.d.ts +65 -0
- package/dist/config/dev.constants.js +79 -0
- package/dist/config/init.constants.d.ts +23 -0
- package/dist/config/init.constants.js +41 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +28 -44
- package/dist/interfaces/admin.d.ts +101 -0
- package/dist/interfaces/admin.js +5 -0
- package/dist/interfaces/agent.d.ts +107 -0
- package/dist/interfaces/agent.js +5 -0
- package/dist/interfaces/baskets.d.ts +135 -0
- package/dist/interfaces/baskets.js +19 -0
- package/dist/interfaces/chat.d.ts +61 -0
- package/dist/interfaces/chat.js +5 -0
- package/dist/interfaces/common.d.ts +62 -0
- package/dist/interfaces/common.js +8 -0
- package/dist/interfaces/compile.d.ts +11 -0
- package/dist/interfaces/compile.js +4 -0
- package/dist/interfaces/custom.data.d.ts +82 -0
- package/dist/interfaces/custom.data.js +5 -0
- package/dist/interfaces/deploy.d.ts +29 -0
- package/dist/interfaces/deploy.js +4 -0
- package/dist/interfaces/dev.d.ts +53 -0
- package/dist/interfaces/dev.js +5 -0
- package/dist/interfaces/init.d.ts +60 -0
- package/dist/interfaces/init.js +4 -0
- package/dist/interfaces/orders.d.ts +91 -0
- package/dist/interfaces/orders.js +19 -0
- package/dist/interfaces/product.d.ts +65 -0
- package/dist/interfaces/product.js +5 -0
- package/dist/interfaces/push.d.ts +26 -0
- package/dist/interfaces/push.js +4 -0
- package/dist/interfaces/test.d.ts +36 -0
- package/dist/interfaces/test.js +4 -0
- package/dist/services/auth.d.ts +54 -99
- package/dist/services/auth.js +76 -12
- package/dist/types/api-contracts.d.ts +211 -0
- package/dist/types/api-contracts.js +8 -0
- package/dist/types/compile.types.d.ts +76 -0
- package/dist/types/compile.types.js +4 -0
- package/dist/types/index.d.ts +23 -85
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -19
- package/dist/types/tool-validation.d.ts +34 -0
- package/dist/types/tool-validation.js +42 -0
- package/dist/utils/auth-flows.d.ts +26 -0
- package/dist/utils/auth-flows.js +141 -0
- package/dist/utils/bundling.d.ts +36 -0
- package/dist/utils/bundling.js +137 -0
- package/dist/utils/compile.d.ts +37 -0
- package/dist/utils/compile.js +242 -0
- package/dist/utils/deploy-api.d.ts +26 -0
- package/dist/utils/deploy-api.js +53 -0
- package/dist/utils/deploy-helpers.d.ts +46 -0
- package/dist/utils/deploy-helpers.js +86 -0
- package/dist/utils/deployment.d.ts +25 -0
- package/dist/utils/deployment.js +161 -0
- package/dist/utils/dev-api.d.ts +61 -0
- package/dist/utils/dev-api.js +262 -0
- package/dist/utils/dev-helpers.d.ts +46 -0
- package/dist/utils/dev-helpers.js +83 -0
- package/dist/utils/dev-server.d.ts +24 -0
- package/dist/utils/dev-server.js +555 -0
- package/dist/utils/dev-watcher.d.ts +31 -0
- package/dist/utils/dev-watcher.js +110 -0
- package/dist/utils/files.js +0 -5
- package/dist/utils/init-agent.d.ts +34 -0
- package/dist/utils/init-agent.js +129 -0
- package/dist/utils/init-helpers.d.ts +41 -0
- package/dist/utils/init-helpers.js +73 -0
- package/dist/utils/init-prompts.d.ts +47 -0
- package/dist/utils/init-prompts.js +168 -0
- package/dist/utils/push-api.d.ts +15 -0
- package/dist/utils/push-api.js +48 -0
- package/dist/utils/push-helpers.d.ts +38 -0
- package/dist/utils/push-helpers.js +84 -0
- package/dist/utils/sandbox-storage.d.ts +27 -0
- package/dist/utils/sandbox-storage.js +71 -0
- package/dist/utils/sandbox.js +78 -118
- package/dist/utils/skill-management.d.ts +14 -0
- package/dist/utils/skill-management.js +148 -0
- package/dist/utils/test-helpers.d.ts +40 -0
- package/dist/utils/test-helpers.js +92 -0
- package/dist/utils/test-prompts.d.ts +23 -0
- package/dist/utils/test-prompts.js +186 -0
- package/dist/utils/tool-detection.d.ts +18 -0
- package/dist/utils/tool-detection.js +110 -0
- package/dist/web/app.css +14 -9
- package/package.json +11 -12
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +81 -40
- package/template/src/tools/BasketTool.ts +128 -0
- package/template/src/tools/CustomDataTool.ts +7 -13
- package/template/src/tools/OrderTool.ts +54 -0
- package/template/src/tools/PaymentTool.ts +1 -1
- package/template/src/tools/ProductsTool.ts +56 -118
- package/template/src/tools/UserDataTool.ts +4 -27
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -197
- package/dist/product-api.js +0 -152
- package/dist/services/api.d.ts +0 -569
- package/dist/services/api.js +0 -625
- package/dist/skill.d.ts +0 -50
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/user-data-api.d.ts +0 -39
- package/dist/user-data-api.js +0 -50
- package/template/API.md +0 -604
- package/template/DEVELOPER.md +0 -771
- package/template/lua.skill.yaml +0 -16
package/README.md
CHANGED
|
@@ -1,545 +1,859 @@
|
|
|
1
1
|
# Lua CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build AI agents with custom capabilities using TypeScript.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/lua-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🎯 What is Lua CLI?
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
**Think of it like:**
|
|
15
|
+
- 🤖 **AI Agent** = Your assistant (like ChatGPT)
|
|
16
|
+
- 🎯 **Skills** = What it can do (your custom capabilities)
|
|
17
|
+
- 🛠️ **Tools** = Specific functions (e.g., "get weather", "create order")
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ⚡ Quick Start
|
|
6
22
|
|
|
7
23
|
```bash
|
|
24
|
+
# Install
|
|
8
25
|
npm install -g lua-cli
|
|
26
|
+
|
|
27
|
+
# Authenticate
|
|
28
|
+
lua auth configure
|
|
29
|
+
|
|
30
|
+
# Create a project
|
|
31
|
+
mkdir my-skill && cd my-skill
|
|
32
|
+
lua init
|
|
33
|
+
|
|
34
|
+
# Test locally
|
|
35
|
+
lua test
|
|
36
|
+
|
|
37
|
+
# Start dev mode
|
|
38
|
+
lua dev
|
|
9
39
|
```
|
|
10
40
|
|
|
11
|
-
|
|
41
|
+
**Done!** Your AI skill is running at http://localhost:3000 🎉
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📦 Installation
|
|
46
|
+
|
|
47
|
+
### Global Installation (Recommended)
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g lua-cli
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Using npx (No Installation)
|
|
14
54
|
|
|
15
55
|
```bash
|
|
16
|
-
lua
|
|
56
|
+
npx lua-cli [command]
|
|
17
57
|
```
|
|
18
58
|
|
|
19
|
-
|
|
59
|
+
### Requirements
|
|
20
60
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- 🛠️ **Skill Development**: Initialize new Lua skills with proper configuration
|
|
25
|
-
- 🔧 **Tool Development**: Create custom tools with TypeScript and Zod validation
|
|
26
|
-
- 📦 **Dependency Bundling**: Automatic bundling of npm packages using esbuild
|
|
27
|
-
- 🧪 **Interactive Testing**: Test your tools with real-time execution
|
|
28
|
-
- 🚀 **Deployment**: Compile and deploy skills to the Lua platform
|
|
29
|
-
- 🔑 **API Key Management**: Securely store, view, and manage your API keys
|
|
30
|
-
- 💾 **User Data API**: Built-in API for persistent user data storage in your tools
|
|
31
|
-
- 📚 **Comprehensive Documentation**: Complete guides and examples
|
|
61
|
+
- **Node.js** 16.0.0 or higher
|
|
62
|
+
- **npm** 7.0.0 or higher
|
|
63
|
+
- **TypeScript** knowledge (for development)
|
|
32
64
|
|
|
33
|
-
|
|
65
|
+
---
|
|
34
66
|
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
lua auth configure
|
|
38
|
-
```
|
|
39
|
-
Choose between API key or email authentication methods.
|
|
67
|
+
## 🚀 Features
|
|
40
68
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
69
|
+
### For Developers
|
|
70
|
+
- 🔨 **TypeScript-first** - Full type safety and autocomplete
|
|
71
|
+
- 🎨 **Template System** - 30+ example tools to learn from
|
|
72
|
+
- 🧪 **Interactive Testing** - Test tools before deployment
|
|
73
|
+
- 🔄 **Live Reload** - Dev mode with automatic recompilation
|
|
74
|
+
- 📦 **Auto Bundling** - Dependencies bundled automatically with esbuild
|
|
75
|
+
- ✅ **Input Validation** - Zod schema validation built-in
|
|
46
76
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
### For Operations
|
|
78
|
+
- 🔐 **Secure Auth** - API key or email OTP authentication
|
|
79
|
+
- 🌐 **Multi-Skill** - Multiple skills in one project
|
|
80
|
+
- 📊 **Version Management** - Push, test, and deploy versions
|
|
81
|
+
- 🎯 **Sandbox Testing** - Test in isolation before production
|
|
82
|
+
- 📝 **Environment Variables** - Secure configuration management
|
|
52
83
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
### For Users
|
|
85
|
+
- 💬 **Chat Interface** - Test your AI in real conversations
|
|
86
|
+
- 🔍 **Tool Explorer** - Browse and test individual tools
|
|
87
|
+
- 📊 **Real-time Logs** - WebSocket log streaming
|
|
88
|
+
- 🎨 **Beautiful UI** - Modern, intuitive interface
|
|
58
89
|
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
lua skill test
|
|
62
|
-
```
|
|
63
|
-
Interactive testing interface for your tools.
|
|
90
|
+
---
|
|
64
91
|
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
lua skill deploy
|
|
68
|
-
```
|
|
69
|
-
Deploy to the Lua platform.
|
|
92
|
+
## 📖 Documentation
|
|
70
93
|
|
|
71
|
-
|
|
94
|
+
### 📘 **For Beginners**
|
|
95
|
+
**[Getting Started Guide](GETTING_STARTED.md)** - Zero to deployed skill in one hour
|
|
96
|
+
- Installation and setup
|
|
97
|
+
- Your first skill
|
|
98
|
+
- Step-by-step tutorial
|
|
99
|
+
- Complete restaurant skill example
|
|
72
100
|
|
|
73
|
-
###
|
|
101
|
+
### 🔧 **For Developers**
|
|
102
|
+
**[API Reference](API_REFERENCE.md)** - Complete API documentation
|
|
103
|
+
- All exported APIs (User, Data, Products, Baskets, Orders)
|
|
104
|
+
- Type definitions
|
|
105
|
+
- Code examples
|
|
106
|
+
- Best practices
|
|
74
107
|
|
|
75
|
-
|
|
108
|
+
**[Template Guide](TEMPLATE_GUIDE.md)** - Understanding the example project
|
|
109
|
+
- Template structure explained
|
|
110
|
+
- 30+ tool examples
|
|
111
|
+
- Building your first skill
|
|
112
|
+
- Common patterns and recipes
|
|
76
113
|
|
|
77
|
-
|
|
114
|
+
### 💻 **For CLI Users**
|
|
115
|
+
**[CLI Reference](CLI_REFERENCE.md)** - All command documentation
|
|
116
|
+
- Complete command reference
|
|
117
|
+
- Flags and options
|
|
118
|
+
- Workflow examples
|
|
119
|
+
- Troubleshooting
|
|
78
120
|
|
|
79
|
-
|
|
80
|
-
|
|
121
|
+
### 🏗️ **For Contributors**
|
|
122
|
+
**[Developer Guide](DEVELOPER_GUIDE.md)** - Architecture and internals
|
|
123
|
+
- Codebase structure
|
|
124
|
+
- Module organization
|
|
125
|
+
- Contributing guidelines
|
|
81
126
|
|
|
82
|
-
|
|
83
|
-
lua auth configure
|
|
84
|
-
```
|
|
127
|
+
---
|
|
85
128
|
|
|
86
|
-
|
|
129
|
+
## 🎓 Core Concepts
|
|
87
130
|
|
|
88
|
-
|
|
131
|
+
### Skills
|
|
89
132
|
|
|
90
|
-
|
|
91
|
-
|
|
133
|
+
A skill is a collection of related tools:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { LuaSkill } from 'lua-cli';
|
|
137
|
+
|
|
138
|
+
const weatherSkill = new LuaSkill({
|
|
139
|
+
name: "weather-skill",
|
|
140
|
+
version: "1.0.0",
|
|
141
|
+
description: "Provides weather information",
|
|
142
|
+
context: "Use get_weather when users ask about weather...",
|
|
143
|
+
tools: [
|
|
144
|
+
new GetWeatherTool(),
|
|
145
|
+
new GetForecastTool()
|
|
146
|
+
]
|
|
147
|
+
});
|
|
92
148
|
```
|
|
93
149
|
|
|
94
|
-
|
|
150
|
+
### Tools
|
|
95
151
|
|
|
96
|
-
|
|
152
|
+
A tool is a single function the AI can call:
|
|
97
153
|
|
|
98
|
-
```
|
|
99
|
-
|
|
154
|
+
```typescript
|
|
155
|
+
import { LuaTool } from 'lua-cli';
|
|
156
|
+
import { z } from 'zod';
|
|
157
|
+
|
|
158
|
+
export default class GetWeatherTool implements LuaTool {
|
|
159
|
+
name = "get_weather";
|
|
160
|
+
description = "Get current weather for a city";
|
|
161
|
+
|
|
162
|
+
inputSchema = z.object({
|
|
163
|
+
city: z.string()
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
async execute(input: any) {
|
|
167
|
+
// Call weather API
|
|
168
|
+
return {
|
|
169
|
+
temperature: 72,
|
|
170
|
+
condition: "sunny",
|
|
171
|
+
city: input.city
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
100
175
|
```
|
|
101
176
|
|
|
102
|
-
###
|
|
177
|
+
### Platform APIs
|
|
103
178
|
|
|
104
|
-
|
|
179
|
+
Built-in APIs for common operations:
|
|
105
180
|
|
|
106
|
-
|
|
181
|
+
```typescript
|
|
182
|
+
import { User, Data, Products, Baskets, Orders } from 'lua-cli';
|
|
107
183
|
|
|
108
|
-
|
|
109
|
-
|
|
184
|
+
// User data
|
|
185
|
+
const user = await User.get();
|
|
186
|
+
|
|
187
|
+
// Custom data with vector search
|
|
188
|
+
await Data.create('movies', movieData, searchText);
|
|
189
|
+
const results = await Data.search('movies', 'sci-fi thriller');
|
|
190
|
+
|
|
191
|
+
// Products
|
|
192
|
+
const products = await Products.search('laptop');
|
|
193
|
+
|
|
194
|
+
// Shopping baskets
|
|
195
|
+
const basket = await Baskets.create({ currency: 'USD' });
|
|
196
|
+
await Baskets.addItem(basketId, { id, price, quantity });
|
|
197
|
+
|
|
198
|
+
// Orders
|
|
199
|
+
const order = await Baskets.placeOrder(orderData, basketId);
|
|
110
200
|
```
|
|
111
201
|
|
|
112
|
-
|
|
113
|
-
- Fetch your organizations and agents from the API
|
|
114
|
-
- Let you select an organization by name
|
|
115
|
-
- **Choose between existing agents or creating a new one:**
|
|
116
|
-
- **Existing Agent**: Select from your current agents
|
|
117
|
-
- **New Agent**: Create a custom agent with:
|
|
118
|
-
- Agent type selection (Base Agent, Shopify, WooCommerce, etc.)
|
|
119
|
-
- Required metadata collection (API keys, IDs, etc.)
|
|
120
|
-
- Feature configuration (RAG, tickets, web search, etc.)
|
|
121
|
-
- Business information (name, type, personality, traits)
|
|
122
|
-
- Automatic persona generation and welcome message
|
|
123
|
-
- Prompt for skill name and description
|
|
124
|
-
- Create a `lua.skill.yaml` configuration file with agent details
|
|
125
|
-
- Copy template files to the current directory
|
|
202
|
+
---
|
|
126
203
|
|
|
127
|
-
|
|
204
|
+
## 💡 Examples
|
|
128
205
|
|
|
129
|
-
|
|
206
|
+
### Example 1: Simple Weather Tool
|
|
130
207
|
|
|
131
|
-
```
|
|
132
|
-
|
|
208
|
+
```typescript
|
|
209
|
+
import { LuaTool } from 'lua-cli';
|
|
210
|
+
import { z } from 'zod';
|
|
211
|
+
|
|
212
|
+
export default class WeatherTool implements LuaTool {
|
|
213
|
+
name = "get_weather";
|
|
214
|
+
description = "Get weather for any city";
|
|
215
|
+
inputSchema = z.object({ city: z.string() });
|
|
216
|
+
|
|
217
|
+
async execute(input: any) {
|
|
218
|
+
const response = await fetch(
|
|
219
|
+
`https://api.open-meteo.com/v1/forecast?city=${input.city}`
|
|
220
|
+
);
|
|
221
|
+
const data = await response.json();
|
|
222
|
+
return { temperature: data.temp, condition: data.condition };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
133
225
|
```
|
|
134
226
|
|
|
135
|
-
|
|
136
|
-
- Scan your tools for imports and dependencies
|
|
137
|
-
- Bundle external packages using esbuild
|
|
138
|
-
- Compress the generated code for efficient storage
|
|
139
|
-
- Create `.lua/deploy.json` with compiled skill data
|
|
140
|
-
- Generate individual tool files in `.lua/` directory
|
|
227
|
+
### Example 2: E-commerce Tool
|
|
141
228
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
229
|
+
```typescript
|
|
230
|
+
import { LuaTool, Products, Baskets } from 'lua-cli';
|
|
231
|
+
import { z } from 'zod';
|
|
145
232
|
|
|
146
|
-
|
|
233
|
+
export default class AddToCartTool implements LuaTool {
|
|
234
|
+
name = "add_to_cart";
|
|
235
|
+
description = "Add product to shopping cart";
|
|
236
|
+
|
|
237
|
+
inputSchema = z.object({
|
|
238
|
+
productId: z.string(),
|
|
239
|
+
quantity: z.number().min(1)
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
async execute(input: any) {
|
|
243
|
+
const product = await Products.getById(input.productId);
|
|
244
|
+
const basket = await Baskets.create({ currency: 'USD' });
|
|
245
|
+
|
|
246
|
+
await Baskets.addItem(basket.id, {
|
|
247
|
+
id: input.productId,
|
|
248
|
+
price: product.price,
|
|
249
|
+
quantity: input.quantity
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
basketId: basket.id,
|
|
254
|
+
message: `Added ${input.quantity}x ${product.name} to cart`
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
147
259
|
|
|
148
|
-
|
|
260
|
+
### Example 3: Custom Data with Search
|
|
149
261
|
|
|
150
|
-
```
|
|
151
|
-
|
|
262
|
+
```typescript
|
|
263
|
+
import { LuaTool, Data } from 'lua-cli';
|
|
264
|
+
import { z } from 'zod';
|
|
265
|
+
|
|
266
|
+
export class CreateMovieTool implements LuaTool {
|
|
267
|
+
name = "create_movie";
|
|
268
|
+
description = "Add a movie to the database";
|
|
269
|
+
|
|
270
|
+
inputSchema = z.object({
|
|
271
|
+
title: z.string(),
|
|
272
|
+
director: z.string(),
|
|
273
|
+
year: z.number()
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
async execute(input: any) {
|
|
277
|
+
const searchText = `${input.title} ${input.director} ${input.year}`;
|
|
278
|
+
const movie = await Data.create('movies', input, searchText);
|
|
279
|
+
return { id: movie.id, message: 'Movie added' };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export class SearchMoviesTool implements LuaTool {
|
|
284
|
+
name = "search_movies";
|
|
285
|
+
description = "Search movies by title, director, or year";
|
|
286
|
+
inputSchema = z.object({ query: z.string() });
|
|
287
|
+
|
|
288
|
+
async execute(input: any) {
|
|
289
|
+
const results = await Data.search('movies', input.query, 10, 0.7);
|
|
290
|
+
return { movies: results.data, count: results.count };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
152
293
|
```
|
|
153
294
|
|
|
154
|
-
|
|
155
|
-
- Tool selection menu
|
|
156
|
-
- Input validation with Zod schemas
|
|
157
|
-
- Real-time execution in isolated VM context
|
|
158
|
-
- Error reporting and debugging
|
|
159
|
-
- Mock data support
|
|
295
|
+
---
|
|
160
296
|
|
|
161
|
-
|
|
297
|
+
## 🎯 Commands
|
|
162
298
|
|
|
163
|
-
|
|
299
|
+
### Authentication
|
|
300
|
+
```bash
|
|
301
|
+
lua auth configure # Set up API key
|
|
302
|
+
lua auth key # Display API key
|
|
303
|
+
lua auth logout # Delete API key
|
|
304
|
+
```
|
|
164
305
|
|
|
306
|
+
### Skill Management
|
|
165
307
|
```bash
|
|
166
|
-
lua skill
|
|
308
|
+
lua init # Create new skill project
|
|
309
|
+
lua compile # Compile TypeScript to deployable format
|
|
310
|
+
lua test # Test tools interactively
|
|
311
|
+
lua push # Upload version to server
|
|
312
|
+
lua deploy # Deploy version to production
|
|
313
|
+
lua dev # Development mode with live reload
|
|
167
314
|
```
|
|
168
315
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
- Send the compiled skill data to the server
|
|
173
|
-
- Store the skill ID in your YAML file
|
|
316
|
+
**See [CLI_REFERENCE.md](CLI_REFERENCE.md) for complete command documentation.**
|
|
317
|
+
|
|
318
|
+
---
|
|
174
319
|
|
|
175
|
-
|
|
320
|
+
## 🛠️ Development Workflow
|
|
176
321
|
|
|
177
|
-
|
|
322
|
+
### Local Development
|
|
178
323
|
|
|
179
324
|
```bash
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
- The sandbox skill ID is securely stored on your machine for future use
|
|
190
|
-
- Display the sandbox skill ID for testing
|
|
191
|
-
- **Web Chat Interface**:
|
|
192
|
-
- Automatically opens a beautiful chat interface in your browser
|
|
193
|
-
- Test your sandbox skill in real-time with natural language
|
|
194
|
-
- Messages are sent to the sandbox environment via the chat API
|
|
195
|
-
- Available at `http://localhost:3000` (opens automatically)
|
|
196
|
-
- **Live Log Panel**:
|
|
197
|
-
- Real-time log feed showing execution details
|
|
198
|
-
- WebSocket connection to `wss://api.heylua.ai/feed`
|
|
199
|
-
- Console-style interface with color-coded log levels
|
|
200
|
-
- Shows tool calls, errors, metrics, and execution metadata
|
|
201
|
-
- Displays detailed information in expandable sections
|
|
202
|
-
- Connection status indicator and automatic reconnection
|
|
203
|
-
- Supports log types: error, debug, warn, info
|
|
204
|
-
- **File Watching Mode**:
|
|
205
|
-
- Watches for file changes in the current directory
|
|
206
|
-
- Automatically recompiles and pushes to sandbox when files change
|
|
207
|
-
- Ignores build artifacts (`.lua/`, `node_modules/`, `.git/`, etc.)
|
|
208
|
-
- Debounces rapid changes to prevent excessive builds
|
|
209
|
-
- Press `Ctrl+C` to stop watching and exit
|
|
210
|
-
|
|
211
|
-
#### `lua skill deploy`
|
|
212
|
-
|
|
213
|
-
Deploy a version to production.
|
|
325
|
+
# Start dev mode
|
|
326
|
+
lua dev
|
|
327
|
+
|
|
328
|
+
# Make changes to src/tools/*.ts
|
|
329
|
+
# Save → Auto-recompiles → Auto-pushes to sandbox
|
|
330
|
+
# Test in browser at http://localhost:3000
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Testing
|
|
214
334
|
|
|
215
335
|
```bash
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
This command will:
|
|
220
|
-
- Fetch available versions from the server
|
|
221
|
-
- Let you select which version to deploy
|
|
222
|
-
- Show a warning about deploying to all users
|
|
223
|
-
- Publish the selected version to production
|
|
224
|
-
|
|
225
|
-
**Requirements:**
|
|
226
|
-
- Valid API key (configured with `lua auth configure`)
|
|
227
|
-
- Compiled skill (run `lua skill compile` first)
|
|
228
|
-
- Active internet connection
|
|
229
|
-
|
|
230
|
-
## Template System
|
|
231
|
-
|
|
232
|
-
The Lua CLI includes a comprehensive template system with examples and documentation:
|
|
233
|
-
|
|
234
|
-
### Template Structure
|
|
235
|
-
```
|
|
236
|
-
template/
|
|
237
|
-
├── README.md # Complete user guide
|
|
238
|
-
├── DEVELOPER.md # Technical documentation
|
|
239
|
-
├── API.md # API reference
|
|
240
|
-
├── QUICKSTART.md # Quick start guide
|
|
241
|
-
├── tools/ # Example tools
|
|
242
|
-
│ ├── GetWeatherTool.ts
|
|
243
|
-
│ ├── GetUserDataTool.ts
|
|
244
|
-
│ ├── CreatePostTool.ts
|
|
245
|
-
│ ├── CalculatorTool.ts
|
|
246
|
-
│ └── AdvancedMathTool.ts
|
|
247
|
-
├── services/ # Example services
|
|
248
|
-
│ ├── ApiService.ts
|
|
249
|
-
│ ├── GetWeather.ts
|
|
250
|
-
│ └── MathService.ts
|
|
251
|
-
└── index.ts # Main skill definition
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Getting Started with Templates
|
|
255
|
-
|
|
256
|
-
1. **Copy the template:**
|
|
257
|
-
```bash
|
|
258
|
-
cp -r template/ my-skill/
|
|
259
|
-
cd my-skill
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
2. **Install dependencies:**
|
|
263
|
-
```bash
|
|
264
|
-
npm install
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
3. **Read the documentation:**
|
|
268
|
-
```bash
|
|
269
|
-
# Start with the quick start guide
|
|
270
|
-
cat QUICKSTART.md
|
|
271
|
-
|
|
272
|
-
# Then read the full documentation
|
|
273
|
-
cat README.md
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
4. **Create your tools:**
|
|
277
|
-
```bash
|
|
278
|
-
# Modify existing tools or create new ones
|
|
279
|
-
# See tools/ directory for examples
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## Configuration File
|
|
283
|
-
|
|
284
|
-
The `lua.skill.yaml` file is created when you run `lua skill init`:
|
|
336
|
+
# Test individual tools
|
|
337
|
+
lua test
|
|
285
338
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
persona: "Generated persona description" # Only for newly created agents
|
|
291
|
-
welcomeMessage: "Welcome message" # Only for newly created agents
|
|
339
|
+
# Test conversationally
|
|
340
|
+
lua dev
|
|
341
|
+
# Use chat interface
|
|
342
|
+
```
|
|
292
343
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
344
|
+
### Deployment
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Upload new version
|
|
348
|
+
lua push
|
|
349
|
+
|
|
350
|
+
# Deploy to production
|
|
351
|
+
lua deploy
|
|
297
352
|
```
|
|
298
353
|
|
|
299
|
-
|
|
354
|
+
---
|
|
300
355
|
|
|
301
|
-
|
|
356
|
+
## 📚 Built-in APIs
|
|
302
357
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
4. The key is validated and stored securely
|
|
358
|
+
### User API
|
|
359
|
+
```typescript
|
|
360
|
+
import { User } from 'lua-cli';
|
|
307
361
|
|
|
308
|
-
|
|
362
|
+
const user = await User.get();
|
|
363
|
+
```
|
|
309
364
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
4. Check your email for the OTP code
|
|
314
|
-
5. Enter the 6-digit OTP code
|
|
315
|
-
6. An API key is automatically generated and stored
|
|
365
|
+
### Custom Data API (with Vector Search)
|
|
366
|
+
```typescript
|
|
367
|
+
import { Data } from 'lua-cli';
|
|
316
368
|
|
|
317
|
-
|
|
369
|
+
await Data.create('collection', data, searchText);
|
|
370
|
+
const results = await Data.search('collection', 'query', limit, threshold);
|
|
371
|
+
```
|
|
318
372
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
- No credentials are stored in plain text
|
|
373
|
+
### Products API
|
|
374
|
+
```typescript
|
|
375
|
+
import { Products } from 'lua-cli';
|
|
323
376
|
|
|
324
|
-
|
|
377
|
+
const products = await Products.search('laptop');
|
|
378
|
+
await Products.create({ name, price });
|
|
379
|
+
```
|
|
325
380
|
|
|
326
|
-
###
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
lua skill init
|
|
381
|
+
### Baskets API
|
|
382
|
+
```typescript
|
|
383
|
+
import { Baskets, BasketStatus } from 'lua-cli';
|
|
330
384
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
cd my-skill
|
|
334
|
-
npm install
|
|
385
|
+
const basket = await Baskets.create({ currency: 'USD' });
|
|
386
|
+
await Baskets.addItem(basketId, { id, price, quantity });
|
|
335
387
|
```
|
|
336
388
|
|
|
337
|
-
###
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
389
|
+
### Orders API
|
|
390
|
+
```typescript
|
|
391
|
+
import { Orders, OrderStatus } from 'lua-cli';
|
|
392
|
+
|
|
393
|
+
const order = await Baskets.placeOrder(orderData, basketId);
|
|
394
|
+
await Orders.updateStatus(OrderStatus.FULFILLED, orderId);
|
|
342
395
|
```
|
|
343
396
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
397
|
+
**See [API_REFERENCE.md](API_REFERENCE.md) for complete API documentation.**
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 🎨 Template Project
|
|
402
|
+
|
|
403
|
+
The template includes 30+ working examples:
|
|
404
|
+
|
|
405
|
+
- 🌤️ **Weather Tool** - External API integration
|
|
406
|
+
- 👤 **User Data Tools** - User management
|
|
407
|
+
- 🛍️ **Product Tools** - E-commerce catalog
|
|
408
|
+
- 🛒 **Basket Tools** - Shopping cart
|
|
409
|
+
- 📦 **Order Tools** - Order processing
|
|
410
|
+
- 🎬 **Custom Data Tools** - Vector search
|
|
411
|
+
- 💳 **Payment Tool** - Payment integration
|
|
412
|
+
|
|
413
|
+
**See [TEMPLATE_GUIDE.md](TEMPLATE_GUIDE.md) for complete template documentation.**
|
|
348
414
|
|
|
349
|
-
|
|
350
|
-
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 🔒 Security
|
|
418
|
+
|
|
419
|
+
- ✅ API keys stored in system keychain
|
|
420
|
+
- ✅ Environment variables for secrets
|
|
421
|
+
- ✅ Secure VM sandbox for tool execution
|
|
422
|
+
- ✅ No hardcoded credentials
|
|
423
|
+
- ✅ HTTPS for all API calls
|
|
424
|
+
|
|
425
|
+
**Best Practices:**
|
|
426
|
+
```typescript
|
|
427
|
+
import { env } from 'lua-cli';
|
|
428
|
+
|
|
429
|
+
// ✅ Good - Use environment variables
|
|
430
|
+
const apiKey = env('EXTERNAL_API_KEY');
|
|
431
|
+
|
|
432
|
+
// ❌ Bad - Hardcoded secrets
|
|
433
|
+
const apiKey = 'sk_abc123';
|
|
351
434
|
```
|
|
352
435
|
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
# Push version to server
|
|
356
|
-
lua skill push
|
|
436
|
+
---
|
|
357
437
|
|
|
358
|
-
|
|
359
|
-
|
|
438
|
+
## 🧪 Testing
|
|
439
|
+
|
|
440
|
+
### Unit Testing
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
import { describe, it, expect } from '@jest/globals';
|
|
444
|
+
import MyTool from './tools/MyTool';
|
|
445
|
+
|
|
446
|
+
describe('MyTool', () => {
|
|
447
|
+
it('should return expected result', async () => {
|
|
448
|
+
const tool = new MyTool();
|
|
449
|
+
const result = await tool.execute({ input: 'test' });
|
|
450
|
+
expect(result).toHaveProperty('success');
|
|
451
|
+
});
|
|
452
|
+
});
|
|
360
453
|
```
|
|
361
454
|
|
|
362
|
-
###
|
|
455
|
+
### Interactive Testing
|
|
456
|
+
|
|
363
457
|
```bash
|
|
364
|
-
|
|
365
|
-
#
|
|
366
|
-
|
|
458
|
+
lua test
|
|
459
|
+
# Select tool → Enter inputs → See results
|
|
460
|
+
```
|
|
367
461
|
|
|
368
|
-
|
|
369
|
-
lua skill push
|
|
462
|
+
### Conversational Testing
|
|
370
463
|
|
|
371
|
-
|
|
372
|
-
lua
|
|
464
|
+
```bash
|
|
465
|
+
lua dev
|
|
466
|
+
# Chat with AI at http://localhost:3000
|
|
373
467
|
```
|
|
374
468
|
|
|
375
|
-
|
|
469
|
+
---
|
|
376
470
|
|
|
377
|
-
|
|
378
|
-
- Valid Lua AI platform account
|
|
379
|
-
- TypeScript knowledge (for tool development)
|
|
380
|
-
- Basic understanding of Zod schemas
|
|
471
|
+
## 🎯 Use Cases
|
|
381
472
|
|
|
382
|
-
|
|
473
|
+
### Customer Service
|
|
474
|
+
- Answer FAQs from knowledge base
|
|
475
|
+
- Look up order status
|
|
476
|
+
- Create support tickets
|
|
477
|
+
- Search documentation
|
|
383
478
|
|
|
384
|
-
|
|
479
|
+
### E-commerce
|
|
480
|
+
- Product search and recommendations
|
|
481
|
+
- Shopping cart management
|
|
482
|
+
- Order creation and tracking
|
|
483
|
+
- Inventory checks
|
|
385
484
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
6. Submit a pull request
|
|
485
|
+
### Booking & Scheduling
|
|
486
|
+
- Check availability
|
|
487
|
+
- Create appointments
|
|
488
|
+
- Send confirmations
|
|
489
|
+
- Manage reservations
|
|
392
490
|
|
|
393
|
-
|
|
491
|
+
### Data Management
|
|
492
|
+
- CRUD operations on custom data
|
|
493
|
+
- Vector search for semantic queries
|
|
494
|
+
- Data aggregation and reporting
|
|
495
|
+
- Integration with external systems
|
|
394
496
|
|
|
395
|
-
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## 📊 Architecture
|
|
396
500
|
|
|
397
|
-
|
|
501
|
+
```
|
|
502
|
+
┌─────────────────┐
|
|
503
|
+
│ AI Agent │
|
|
504
|
+
│ (Lua Platform)│
|
|
505
|
+
└────────┬────────┘
|
|
506
|
+
│
|
|
507
|
+
↓
|
|
508
|
+
┌─────────────────┐
|
|
509
|
+
│ Your Skills │ ← Built with Lua CLI
|
|
510
|
+
│ (TypeScript) │
|
|
511
|
+
└────────┬────────┘
|
|
512
|
+
│
|
|
513
|
+
↓
|
|
514
|
+
┌─────────────────┐
|
|
515
|
+
│ Your Tools │
|
|
516
|
+
│ (Functions) │
|
|
517
|
+
└────────┬────────┘
|
|
518
|
+
│
|
|
519
|
+
↓
|
|
520
|
+
┌─────────────────┐
|
|
521
|
+
│ Platform APIs │ ← User, Products, Data, etc.
|
|
522
|
+
│ External APIs │ ← Weather, Stripe, SendGrid, etc.
|
|
523
|
+
│ Databases │ ← Your own systems
|
|
524
|
+
└─────────────────┘
|
|
525
|
+
```
|
|
398
526
|
|
|
399
|
-
|
|
527
|
+
---
|
|
400
528
|
|
|
401
|
-
|
|
529
|
+
## 🌟 Key Features
|
|
402
530
|
|
|
531
|
+
### Type-Safe Development
|
|
403
532
|
```typescript
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const userData = await user.data.get();
|
|
408
|
-
console.log('User data:', userData);
|
|
409
|
-
|
|
410
|
-
// Create or update user data
|
|
411
|
-
await user.data.create({
|
|
412
|
-
name: 'John Doe',
|
|
413
|
-
preferences: {
|
|
414
|
-
theme: 'dark',
|
|
415
|
-
language: 'en'
|
|
416
|
-
}
|
|
417
|
-
});
|
|
533
|
+
// Full TypeScript support
|
|
534
|
+
import { LuaTool, Products } from 'lua-cli';
|
|
535
|
+
import { z } from 'zod';
|
|
418
536
|
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
537
|
+
// Autocomplete, type checking, and validation
|
|
538
|
+
export default class MyTool implements LuaTool {
|
|
539
|
+
inputSchema = z.object({
|
|
540
|
+
query: z.string() // Validated at runtime
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
544
|
+
// input is fully typed!
|
|
545
|
+
return await Products.search(input.query);
|
|
425
546
|
}
|
|
426
|
-
}
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### Instant Feedback
|
|
551
|
+
```bash
|
|
552
|
+
lua dev
|
|
553
|
+
# Edit file → Save → Auto-reload → Test immediately
|
|
554
|
+
```
|
|
427
555
|
|
|
428
|
-
|
|
429
|
-
|
|
556
|
+
### Production Ready
|
|
557
|
+
```bash
|
|
558
|
+
lua push # Upload to server
|
|
559
|
+
lua deploy # Deploy to all users
|
|
430
560
|
```
|
|
431
561
|
|
|
432
|
-
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## 📖 Learning Resources
|
|
565
|
+
|
|
566
|
+
### 🟢 **New to Lua?**
|
|
567
|
+
Start here: **[GETTING_STARTED.md](GETTING_STARTED.md)**
|
|
568
|
+
- Installation
|
|
569
|
+
- First skill in 1 hour
|
|
570
|
+
- Complete tutorial
|
|
571
|
+
- Common patterns
|
|
572
|
+
|
|
573
|
+
### 🟡 **Building Skills?**
|
|
574
|
+
Read: **[API_REFERENCE.md](API_REFERENCE.md)**
|
|
575
|
+
- All exported APIs
|
|
576
|
+
- Type definitions
|
|
577
|
+
- Code examples
|
|
578
|
+
- Best practices
|
|
579
|
+
|
|
580
|
+
### 🟠 **Understanding Examples?**
|
|
581
|
+
Read: **[TEMPLATE_GUIDE.md](TEMPLATE_GUIDE.md)**
|
|
582
|
+
- Template structure
|
|
583
|
+
- 30+ tool examples
|
|
584
|
+
- Common recipes
|
|
585
|
+
- Migration guide
|
|
586
|
+
|
|
587
|
+
### 🔵 **Using the CLI?**
|
|
588
|
+
Read: **[CLI_REFERENCE.md](CLI_REFERENCE.md)**
|
|
589
|
+
- All commands
|
|
590
|
+
- Flags and options
|
|
591
|
+
- Workflows
|
|
592
|
+
- Troubleshooting
|
|
593
|
+
|
|
594
|
+
### 🟣 **Contributing?**
|
|
595
|
+
Read: **[DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)**
|
|
596
|
+
- Architecture
|
|
597
|
+
- Module structure
|
|
598
|
+
- Contribution guidelines
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
## 🔧 Common Tasks
|
|
603
|
+
|
|
604
|
+
### Create a New Tool
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
# Create file
|
|
608
|
+
touch src/tools/MyTool.ts
|
|
609
|
+
```
|
|
433
610
|
|
|
434
611
|
```typescript
|
|
435
|
-
import { LuaTool } from 'lua-cli
|
|
436
|
-
import { user } from 'lua-cli/user-data-api';
|
|
612
|
+
import { LuaTool } from 'lua-cli';
|
|
437
613
|
import { z } from 'zod';
|
|
438
614
|
|
|
439
|
-
export class
|
|
440
|
-
|
|
441
|
-
|
|
615
|
+
export default class MyTool implements LuaTool {
|
|
616
|
+
name = "my_tool";
|
|
617
|
+
description = "What it does";
|
|
618
|
+
inputSchema = z.object({ param: z.string() });
|
|
619
|
+
|
|
620
|
+
async execute(input: any) {
|
|
621
|
+
// Your logic here
|
|
622
|
+
return { success: true };
|
|
442
623
|
}
|
|
624
|
+
}
|
|
625
|
+
```
|
|
443
626
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
case 'clear':
|
|
470
|
-
await user.data.clear();
|
|
471
|
-
return { success: true, message: 'All preferences cleared' };
|
|
472
|
-
|
|
473
|
-
default:
|
|
474
|
-
throw new Error('Invalid action. Use: get, set, or clear');
|
|
475
|
-
}
|
|
627
|
+
Add to skill in `src/index.ts`:
|
|
628
|
+
```typescript
|
|
629
|
+
import MyTool from './tools/MyTool';
|
|
630
|
+
|
|
631
|
+
const skill = new LuaSkill({
|
|
632
|
+
tools: [new MyTool()]
|
|
633
|
+
});
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
### Call External APIs
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
import { LuaTool, env } from 'lua-cli';
|
|
642
|
+
|
|
643
|
+
export default class ExternalApiTool implements LuaTool {
|
|
644
|
+
async execute(input: any) {
|
|
645
|
+
const apiKey = env('EXTERNAL_API_KEY');
|
|
646
|
+
|
|
647
|
+
const response = await fetch('https://api.example.com/data', {
|
|
648
|
+
headers: { 'Authorization': `Bearer ${apiKey}` }
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
return await response.json();
|
|
476
652
|
}
|
|
653
|
+
}
|
|
654
|
+
```
|
|
477
655
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
656
|
+
---
|
|
657
|
+
|
|
658
|
+
### Use Platform APIs
|
|
659
|
+
|
|
660
|
+
```typescript
|
|
661
|
+
import { LuaTool, Products, Baskets } from 'lua-cli';
|
|
662
|
+
|
|
663
|
+
export default class ShoppingTool implements LuaTool {
|
|
664
|
+
async execute(input: any) {
|
|
665
|
+
// Search products
|
|
666
|
+
const products = await Products.search(input.query);
|
|
667
|
+
|
|
668
|
+
// Create basket
|
|
669
|
+
const basket = await Baskets.create({ currency: 'USD' });
|
|
670
|
+
|
|
671
|
+
// Add item
|
|
672
|
+
await Baskets.addItem(basket.id, {
|
|
673
|
+
id: products.data[0].id,
|
|
674
|
+
price: products.data[0].price,
|
|
675
|
+
quantity: 1
|
|
483
676
|
});
|
|
677
|
+
|
|
678
|
+
return { basketId: basket.id };
|
|
484
679
|
}
|
|
485
680
|
}
|
|
486
681
|
```
|
|
487
682
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
### Store Custom Data
|
|
686
|
+
|
|
687
|
+
```typescript
|
|
688
|
+
import { LuaTool, Data } from 'lua-cli';
|
|
689
|
+
|
|
690
|
+
export default class SaveNoteTool implements LuaTool {
|
|
691
|
+
async execute(input: any) {
|
|
692
|
+
// Create
|
|
693
|
+
const note = await Data.create('notes', {
|
|
694
|
+
title: input.title,
|
|
695
|
+
content: input.content,
|
|
696
|
+
tags: input.tags
|
|
697
|
+
}, `${input.title} ${input.content}`);
|
|
698
|
+
|
|
699
|
+
// Search later
|
|
700
|
+
const results = await Data.search('notes', 'meeting notes', 10);
|
|
701
|
+
|
|
702
|
+
return { noteId: note.id };
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## 🎯 Example Projects
|
|
710
|
+
|
|
711
|
+
### Knowledge Base Assistant
|
|
712
|
+
```typescript
|
|
713
|
+
Tools: search_kb, create_article, update_article
|
|
714
|
+
APIs: Data (vector search)
|
|
715
|
+
Use Case: Company documentation, FAQ
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
### E-commerce Bot
|
|
719
|
+
```typescript
|
|
720
|
+
Tools: search_products, add_to_cart, checkout
|
|
721
|
+
APIs: Products, Baskets, Orders
|
|
722
|
+
Use Case: Online shopping assistant
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
### Booking System
|
|
726
|
+
```typescript
|
|
727
|
+
Tools: check_availability, make_reservation, cancel_booking
|
|
728
|
+
APIs: Data (custom collections)
|
|
729
|
+
Use Case: Restaurant/hotel reservations
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
### CRM Assistant
|
|
733
|
+
```typescript
|
|
734
|
+
Tools: find_customer, create_lead, update_contact
|
|
735
|
+
APIs: Data, User
|
|
736
|
+
Use Case: Customer relationship management
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
---
|
|
740
|
+
|
|
741
|
+
## 🚀 Deployment
|
|
742
|
+
|
|
743
|
+
### Development → Production Flow
|
|
744
|
+
|
|
745
|
+
```bash
|
|
746
|
+
# 1. Develop locally
|
|
747
|
+
lua dev
|
|
748
|
+
# Edit, test, iterate
|
|
749
|
+
|
|
750
|
+
# 2. Push to server
|
|
751
|
+
lua push
|
|
752
|
+
|
|
753
|
+
# 3. Test in sandbox
|
|
754
|
+
lua dev
|
|
755
|
+
# Final testing
|
|
756
|
+
|
|
757
|
+
# 4. Deploy to production
|
|
758
|
+
lua deploy
|
|
759
|
+
# Available to all users!
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### Version Management
|
|
763
|
+
|
|
764
|
+
Update version in `lua.skill.yaml`:
|
|
765
|
+
```yaml
|
|
766
|
+
skills:
|
|
767
|
+
- name: my-skill
|
|
768
|
+
version: 1.0.1 # ← Increment this
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
Then push and deploy:
|
|
772
|
+
```bash
|
|
773
|
+
lua push # Uploads v1.0.1
|
|
774
|
+
lua deploy # Deploys v1.0.1
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
---
|
|
778
|
+
|
|
779
|
+
## ⚙️ Configuration
|
|
780
|
+
|
|
781
|
+
### Environment Variables
|
|
782
|
+
|
|
783
|
+
**`.env` file:**
|
|
784
|
+
```bash
|
|
785
|
+
STRIPE_API_KEY=sk_test_abc123
|
|
786
|
+
SENDGRID_KEY=SG.xyz789
|
|
787
|
+
CUSTOM_API_URL=https://api.example.com
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
**`lua.skill.yaml`:**
|
|
791
|
+
```yaml
|
|
792
|
+
skill:
|
|
793
|
+
env:
|
|
794
|
+
PRODUCTION_API_KEY: sk_live_abc123
|
|
795
|
+
BASE_URL: https://prod.example.com
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
**Access in code:**
|
|
799
|
+
```typescript
|
|
800
|
+
import { env } from 'lua-cli';
|
|
801
|
+
|
|
802
|
+
const key = env('STRIPE_API_KEY');
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
---
|
|
806
|
+
|
|
807
|
+
## 🤝 Contributing
|
|
808
|
+
|
|
809
|
+
We welcome contributions!
|
|
810
|
+
|
|
811
|
+
1. Fork the repository
|
|
812
|
+
2. Create a feature branch
|
|
813
|
+
3. Make your changes
|
|
814
|
+
4. Write tests
|
|
815
|
+
5. Submit a pull request
|
|
816
|
+
|
|
817
|
+
See [DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md) for architecture details.
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## 📄 License
|
|
822
|
+
|
|
823
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
824
|
+
|
|
825
|
+
---
|
|
826
|
+
|
|
827
|
+
## 🔗 Links
|
|
828
|
+
|
|
829
|
+
- **Documentation**: https://docs.lua.ai
|
|
830
|
+
- **Platform**: https://heylua.ai
|
|
831
|
+
- **GitHub**: https://github.com/lua-ai/lua-cli
|
|
832
|
+
- **npm**: https://www.npmjs.com/package/lua-cli
|
|
833
|
+
|
|
834
|
+
---
|
|
835
|
+
|
|
836
|
+
## 💬 Support
|
|
837
|
+
|
|
838
|
+
- **Issues**: [GitHub Issues](https://github.com/lua-ai/lua-cli/issues)
|
|
839
|
+
- **Email**: support@lua.ai
|
|
840
|
+
- **Docs**: https://docs.lua.ai
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## 🎉 Quick Links
|
|
845
|
+
|
|
846
|
+
| I want to... | Read this... |
|
|
847
|
+
|--------------|--------------|
|
|
848
|
+
| **Get started** | [GETTING_STARTED.md](GETTING_STARTED.md) |
|
|
849
|
+
| **Learn the API** | [API_REFERENCE.md](API_REFERENCE.md) |
|
|
850
|
+
| **Use CLI commands** | [CLI_REFERENCE.md](CLI_REFERENCE.md) |
|
|
851
|
+
| **Understand examples** | [TEMPLATE_GUIDE.md](TEMPLATE_GUIDE.md) |
|
|
852
|
+
| **Contribute code** | [DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md) |
|
|
853
|
+
| **See changelog** | [CHANGELOG.md](CHANGELOG.md) |
|
|
854
|
+
|
|
855
|
+
---
|
|
856
|
+
|
|
857
|
+
**Happy building! 🚀**
|
|
858
|
+
|
|
859
|
+
Made with ❤️ by the Lua team
|