lua-cli 2.2.8-alpha.2 → 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.
Files changed (193) hide show
  1. package/API_REFERENCE.md +1408 -0
  2. package/CLI_REFERENCE.md +818 -0
  3. package/GETTING_STARTED.md +1040 -0
  4. package/README.md +738 -424
  5. package/TEMPLATE_GUIDE.md +1398 -0
  6. package/dist/api/agent.api.service.d.ts +33 -6
  7. package/dist/api/agent.api.service.js +27 -0
  8. package/dist/api/auth.api.service.d.ts +31 -2
  9. package/dist/api/auth.api.service.js +29 -0
  10. package/dist/api/basket.api.service.d.ts +53 -11
  11. package/dist/api/basket.api.service.js +63 -14
  12. package/dist/api/chat.api.service.d.ts +15 -3
  13. package/dist/api/chat.api.service.js +12 -0
  14. package/dist/api/credentials.d.ts +24 -0
  15. package/dist/api/credentials.js +46 -0
  16. package/dist/api/custom.data.api.service.d.ts +45 -9
  17. package/dist/api/custom.data.api.service.js +43 -9
  18. package/dist/api/lazy-instances.d.ts +49 -0
  19. package/dist/api/lazy-instances.js +95 -0
  20. package/dist/api/order.api.service.d.ts +34 -4
  21. package/dist/api/order.api.service.js +41 -3
  22. package/dist/api/products.api.service.d.ts +39 -9
  23. package/dist/api/products.api.service.js +43 -5
  24. package/dist/api/skills.api.service.d.ts +49 -2
  25. package/dist/api/skills.api.service.js +47 -1
  26. package/dist/api/tool.api.service.d.ts +39 -1
  27. package/dist/api/tool.api.service.js +38 -0
  28. package/dist/api/user.data.api.service.d.ts +23 -1
  29. package/dist/api/user.data.api.service.js +22 -0
  30. package/dist/api-exports.d.ts +236 -5
  31. package/dist/api-exports.js +264 -81
  32. package/dist/cli/command-definitions.d.ts +30 -0
  33. package/dist/cli/command-definitions.js +71 -0
  34. package/dist/commands/agents.d.ts +20 -0
  35. package/dist/commands/agents.js +24 -2
  36. package/dist/commands/apiKey.d.ts +23 -0
  37. package/dist/commands/apiKey.js +23 -0
  38. package/dist/commands/compile.d.ts +24 -0
  39. package/dist/commands/compile.js +67 -759
  40. package/dist/commands/configure.d.ts +24 -0
  41. package/dist/commands/configure.js +31 -96
  42. package/dist/commands/deploy.d.ts +31 -19
  43. package/dist/commands/deploy.js +45 -74
  44. package/dist/commands/destroy.d.ts +27 -0
  45. package/dist/commands/destroy.js +27 -1
  46. package/dist/commands/dev.d.ts +25 -62
  47. package/dist/commands/dev.js +58 -878
  48. package/dist/commands/init.d.ts +27 -0
  49. package/dist/commands/init.js +98 -260
  50. package/dist/commands/push.d.ts +24 -21
  51. package/dist/commands/push.js +39 -92
  52. package/dist/commands/test.d.ts +26 -0
  53. package/dist/commands/test.js +41 -188
  54. package/dist/common/basket.instance.d.ts +54 -3
  55. package/dist/common/basket.instance.js +56 -3
  56. package/dist/common/data.entry.instance.d.ts +25 -2
  57. package/dist/common/data.entry.instance.js +24 -0
  58. package/dist/common/http.client.d.ts +51 -1
  59. package/dist/common/http.client.js +50 -0
  60. package/dist/common/order.instance.d.ts +22 -0
  61. package/dist/common/order.instance.js +31 -4
  62. package/dist/common/product.instance.d.ts +22 -1
  63. package/dist/common/product.instance.js +24 -6
  64. package/dist/common/product.pagination.instance.d.ts +22 -2
  65. package/dist/common/product.pagination.instance.js +22 -1
  66. package/dist/common/product.search.instance.d.ts +13 -3
  67. package/dist/common/product.search.instance.js +12 -1
  68. package/dist/common/user.instance.d.ts +27 -3
  69. package/dist/common/user.instance.js +28 -7
  70. package/dist/config/auth.constants.d.ts +11 -0
  71. package/dist/config/auth.constants.js +11 -0
  72. package/dist/config/compile.constants.d.ts +67 -0
  73. package/dist/config/compile.constants.js +99 -0
  74. package/dist/config/constants.d.ts +5 -0
  75. package/dist/config/constants.js +5 -0
  76. package/dist/config/dev.constants.d.ts +65 -0
  77. package/dist/config/dev.constants.js +79 -0
  78. package/dist/config/init.constants.d.ts +23 -0
  79. package/dist/config/init.constants.js +41 -0
  80. package/dist/index.d.ts +19 -3
  81. package/dist/index.js +28 -44
  82. package/dist/interfaces/admin.d.ts +56 -50
  83. package/dist/interfaces/admin.js +4 -0
  84. package/dist/interfaces/agent.d.ts +21 -0
  85. package/dist/interfaces/agent.js +4 -0
  86. package/dist/interfaces/baskets.d.ts +60 -0
  87. package/dist/interfaces/baskets.js +12 -0
  88. package/dist/interfaces/chat.d.ts +48 -4
  89. package/dist/interfaces/chat.js +4 -0
  90. package/dist/interfaces/common.d.ts +62 -0
  91. package/dist/interfaces/common.js +8 -0
  92. package/dist/interfaces/compile.d.ts +11 -0
  93. package/dist/interfaces/compile.js +4 -0
  94. package/dist/interfaces/custom.data.d.ts +49 -19
  95. package/dist/interfaces/custom.data.js +4 -0
  96. package/dist/interfaces/deploy.d.ts +29 -0
  97. package/dist/interfaces/deploy.js +4 -0
  98. package/dist/interfaces/dev.d.ts +53 -0
  99. package/dist/interfaces/dev.js +5 -0
  100. package/dist/interfaces/init.d.ts +60 -0
  101. package/dist/interfaces/init.js +4 -0
  102. package/dist/interfaces/orders.d.ts +37 -0
  103. package/dist/interfaces/orders.js +12 -0
  104. package/dist/interfaces/product.d.ts +38 -10
  105. package/dist/interfaces/product.js +4 -0
  106. package/dist/interfaces/push.d.ts +26 -0
  107. package/dist/interfaces/push.js +4 -0
  108. package/dist/interfaces/test.d.ts +36 -0
  109. package/dist/interfaces/test.js +4 -0
  110. package/dist/services/auth.d.ts +54 -99
  111. package/dist/services/auth.js +76 -12
  112. package/dist/types/api-contracts.d.ts +211 -0
  113. package/dist/types/api-contracts.js +8 -0
  114. package/dist/types/compile.types.d.ts +76 -0
  115. package/dist/types/compile.types.js +4 -0
  116. package/dist/types/index.d.ts +23 -121
  117. package/dist/types/index.js +25 -14
  118. package/dist/types/skill.d.ts +142 -0
  119. package/dist/{skill.js → types/skill.js} +66 -17
  120. package/dist/types/tool-validation.d.ts +34 -0
  121. package/dist/types/tool-validation.js +42 -0
  122. package/dist/utils/auth-flows.d.ts +26 -0
  123. package/dist/utils/auth-flows.js +141 -0
  124. package/dist/utils/bundling.d.ts +36 -0
  125. package/dist/utils/bundling.js +137 -0
  126. package/dist/utils/compile.d.ts +37 -0
  127. package/dist/utils/compile.js +242 -0
  128. package/dist/utils/deploy-api.d.ts +26 -0
  129. package/dist/utils/deploy-api.js +53 -0
  130. package/dist/utils/deploy-helpers.d.ts +46 -0
  131. package/dist/utils/deploy-helpers.js +86 -0
  132. package/dist/utils/deployment.d.ts +25 -0
  133. package/dist/utils/deployment.js +161 -0
  134. package/dist/utils/dev-api.d.ts +61 -0
  135. package/dist/utils/dev-api.js +262 -0
  136. package/dist/utils/dev-helpers.d.ts +46 -0
  137. package/dist/utils/dev-helpers.js +83 -0
  138. package/dist/utils/dev-server.d.ts +24 -0
  139. package/dist/utils/dev-server.js +555 -0
  140. package/dist/utils/dev-watcher.d.ts +31 -0
  141. package/dist/utils/dev-watcher.js +110 -0
  142. package/dist/utils/files.js +0 -5
  143. package/dist/utils/init-agent.d.ts +34 -0
  144. package/dist/utils/init-agent.js +129 -0
  145. package/dist/utils/init-helpers.d.ts +41 -0
  146. package/dist/utils/init-helpers.js +73 -0
  147. package/dist/utils/init-prompts.d.ts +47 -0
  148. package/dist/utils/init-prompts.js +168 -0
  149. package/dist/utils/push-api.d.ts +15 -0
  150. package/dist/utils/push-api.js +48 -0
  151. package/dist/utils/push-helpers.d.ts +38 -0
  152. package/dist/utils/push-helpers.js +84 -0
  153. package/dist/utils/sandbox-storage.d.ts +27 -0
  154. package/dist/utils/sandbox-storage.js +71 -0
  155. package/dist/utils/sandbox.js +78 -114
  156. package/dist/utils/skill-management.d.ts +14 -0
  157. package/dist/utils/skill-management.js +148 -0
  158. package/dist/utils/test-helpers.d.ts +40 -0
  159. package/dist/utils/test-helpers.js +92 -0
  160. package/dist/utils/test-prompts.d.ts +23 -0
  161. package/dist/utils/test-prompts.js +186 -0
  162. package/dist/utils/tool-detection.d.ts +18 -0
  163. package/dist/utils/tool-detection.js +110 -0
  164. package/dist/web/app.css +14 -9
  165. package/package.json +7 -4
  166. package/template/QUICKSTART.md +299 -144
  167. package/template/README.md +928 -349
  168. package/template/TOOL_EXAMPLES.md +655 -0
  169. package/template/package-lock.json +5 -5
  170. package/template/package.json +1 -1
  171. package/template/src/index.ts +147 -207
  172. package/template/src/tools/BasketTool.ts +128 -0
  173. package/template/src/tools/CustomDataTool.ts +7 -13
  174. package/template/src/tools/OrderTool.ts +54 -0
  175. package/template/src/tools/PaymentTool.ts +1 -1
  176. package/template/src/tools/ProductsTool.ts +56 -118
  177. package/template/src/tools/UserDataTool.ts +4 -26
  178. package/dist/common/config.d.ts +0 -5
  179. package/dist/common/config.js +0 -5
  180. package/dist/custom-data-api.d.ts +0 -72
  181. package/dist/custom-data-api.js +0 -174
  182. package/dist/product-api.d.ts +0 -189
  183. package/dist/product-api.js +0 -141
  184. package/dist/services/api.d.ts +0 -549
  185. package/dist/services/api.js +0 -596
  186. package/dist/skill.d.ts +0 -50
  187. package/dist/types.d.ts +0 -1
  188. package/dist/types.js +0 -2
  189. package/dist/user-data-api.d.ts +0 -39
  190. package/dist/user-data-api.js +0 -50
  191. package/template/API.md +0 -604
  192. package/template/DEVELOPER.md +0 -771
  193. package/template/lua.skill.yaml +0 -7
@@ -1,477 +1,1056 @@
1
- # LuaSkill Template
1
+ # Your Lua AI Skill Project
2
2
 
3
- This template provides a skeleton implementation demonstrating how to build LuaSkills with custom tools using the Lua CLI framework.
3
+ Welcome to your Lua AI skill project! This project is ready to customize and deploy.
4
+
5
+ ---
6
+
7
+ ## 🎯 What You Have
8
+
9
+ This project includes:
10
+ - ✅ **7 Example Skills** - Pre-configured skill examples
11
+ - ✅ **30+ Example Tools** - Working tool implementations
12
+ - ✅ **All Platform APIs** - User, Products, Baskets, Orders, Custom Data
13
+ - ✅ **TypeScript Setup** - Full type safety
14
+ - ✅ **Ready to Deploy** - Just customize and go!
15
+
16
+ ---
4
17
 
5
18
  ## 🚀 Quick Start
6
19
 
7
- 1. **Install the Lua CLI globally:**
8
- ```bash
9
- npm install -g lua-cli
10
- ```
20
+ ```bash
21
+ # 1. Test a tool locally
22
+ npm run test
23
+ # or
24
+ lua test
25
+
26
+ # 2. Start development mode (live reload + chat interface)
27
+ npm run dev
28
+ # or
29
+ lua dev
11
30
 
12
- 2. **Initialize a new LuaSkill project:**
13
- ```bash
14
- mkdir my-lua-skill
15
- cd my-lua-skill
16
- lua init
17
- ```
31
+ # 3. Push to server
32
+ npm run push
33
+ # or
34
+ lua push
18
35
 
19
- 3. **Compile your skill:**
20
- ```bash
21
- lua compile
22
- ```
36
+ # 4. Deploy to production
37
+ lua deploy
38
+ ```
23
39
 
24
- 4. **Test your tools:**
25
- ```bash
26
- lua test
27
- ```
40
+ **Your AI is now live!** 🎉
41
+
42
+ ---
28
43
 
29
44
  ## 📁 Project Structure
30
45
 
31
46
  ```
32
- my-lua-skill/
33
- ├── tools/ # Your custom tools
34
- │ ├── GetWeatherTool.ts
35
- ├── GetUserDataTool.ts
36
- └── CreatePostTool.ts
37
- ├── services/ # Shared services
38
- ├── ApiService.ts
39
- └── GetWeather.ts
40
- ├── index.ts # Main skill definition
41
- ├── package.json # Dependencies
42
- └── .lua/ # Generated files (auto-created)
43
- ├── deploy.json # Compiled skill data
44
- └── *.js # Bundled tool files
47
+ your-project/
48
+ ├── src/
49
+ │ ├── index.ts # YOUR STARTING POINT - Define skills here
50
+ └── tools/ # Tool implementations
51
+ ├── GetWeatherTool.ts # External API example
52
+ ├── UserDataTool.ts # User API example
53
+ ├── ProductsTool.ts # Products API (6 tools)
54
+ ├── BasketTool.ts # Baskets API (9 tools)
55
+ ├── OrderTool.ts # Orders API (4 tools)
56
+ ├── CustomDataTool.ts # Custom Data API (6 tools)
57
+ │ ├── PaymentTool.ts # Payment integration
58
+ │ └── CreatePostTool.ts # Simple example
59
+ ├── lua.skill.yaml # Configuration (auto-managed)
60
+ ├── package.json # Dependencies
61
+ ├── tsconfig.json # TypeScript config
62
+ ├── .env # Environment variables (create this)
63
+ └── README.md # This file
45
64
  ```
46
65
 
47
- ## 🛠️ Creating Tools
66
+ ---
67
+
68
+ ## 🎓 Getting Started
48
69
 
49
- ### Basic Tool Structure
70
+ ### Step 1: Understand the Template
50
71
 
51
- Every tool must implement the `LuaTool` interface:
72
+ Open **`src/index.ts`** - this is where your skills are defined:
52
73
 
53
74
  ```typescript
54
- import { LuaTool } from "lua-cli/skill";
75
+ // Example: General purpose skill
76
+ const generalSkill = new LuaSkill({
77
+ name: "general-skill",
78
+ version: "0.0.2",
79
+ description: "Weather and utility tools",
80
+ context: "Use get_weather for weather info...",
81
+ tools: [
82
+ new GetWeatherTool(),
83
+ new CreatePostTool()
84
+ ]
85
+ });
86
+ ```
87
+
88
+ **You have 7 skills pre-configured:**
89
+ 1. `general-skill` - Weather and posts
90
+ 2. `user-data-skill` - User management
91
+ 3. `product-skill` - Product catalog
92
+ 4. `basket-skill` - Shopping carts
93
+ 5. `order-skill` - Order processing
94
+ 6. `custom-data-skill` - Custom data (movies example)
95
+ 7. `payment-skill` - Payment links
96
+
97
+ ---
98
+
99
+ ### Step 2: Test the Examples
100
+
101
+ ```bash
102
+ lua test
103
+ ```
104
+
105
+ **Try these tools:**
106
+ - `get_weather` - Enter city: "London"
107
+ - `search_products` - Enter query: "laptop"
108
+ - `create_movie` - Enter title, director, year
109
+ - `get_user_data` - No input needed
110
+
111
+ ---
112
+
113
+ ### Step 3: Start Dev Mode
114
+
115
+ ```bash
116
+ lua dev
117
+ ```
118
+
119
+ **Opens chat interface at http://localhost:3000**
120
+
121
+ **Try chatting:**
122
+ - "What's the weather in Tokyo?"
123
+ - "Show me your products"
124
+ - "Create a shopping basket"
125
+ - "Add product XYZ to my basket"
126
+
127
+ ---
128
+
129
+ ### Step 4: Customize for Your Use Case
130
+
131
+ #### Option A: Modify Existing Tools
132
+
133
+ Edit `src/tools/GetWeatherTool.ts`:
134
+ ```typescript
135
+ async execute(input: any) {
136
+ const weather = await this.getWeather(input.city);
137
+
138
+ // Add your customization
139
+ return {
140
+ ...weather,
141
+ recommendation: this.getClothingAdvice(weather.temperature)
142
+ };
143
+ }
144
+ ```
145
+
146
+ #### Option B: Remove Unused Skills
147
+
148
+ Clean up `src/index.ts`:
149
+ ```typescript
150
+ // Remove skills you don't need
151
+ // Keep only what's relevant to your use case
152
+
153
+ import { LuaSkill } from "lua-cli";
154
+ import GetWeatherTool from "./tools/GetWeatherTool";
155
+
156
+ const mySkill = new LuaSkill({
157
+ name: "my-custom-skill",
158
+ version: "1.0.0",
159
+ description: "My specific use case",
160
+ context: "Clear instructions for the AI...",
161
+ tools: [
162
+ new GetWeatherTool()
163
+ // Add your tools
164
+ ]
165
+ });
166
+ ```
167
+
168
+ #### Option C: Create New Tools
169
+
170
+ Create `src/tools/MyTool.ts`:
171
+ ```typescript
172
+ import { LuaTool } from "lua-cli";
55
173
  import { z } from "zod";
56
174
 
57
- export default class MyTool implements LuaTool<z.ZodObject<any>, z.ZodObject<any>> {
175
+ export default class MyTool implements LuaTool {
58
176
  name = "my_tool";
59
- description = "Description of what this tool does";
177
+ description = "What my tool does";
60
178
 
61
179
  inputSchema = z.object({
62
- // Define your input parameters
63
- param1: z.string().describe("Description of param1"),
64
- param2: z.number().describe("Description of param2")
65
- });
66
-
67
- outputSchema = z.object({
68
- // Define your output structure
69
- result: z.string(),
70
- success: z.boolean()
180
+ param: z.string()
71
181
  });
72
-
182
+
73
183
  async execute(input: z.infer<typeof this.inputSchema>) {
74
- // Your tool logic here
75
- return {
76
- result: "Tool executed successfully",
77
- success: true
78
- };
184
+ // Your logic here
185
+ return { success: true };
79
186
  }
80
187
  }
81
188
  ```
82
189
 
83
- ### Tool Examples
190
+ Add to `src/index.ts`:
191
+ ```typescript
192
+ import MyTool from "./tools/MyTool";
193
+
194
+ const mySkill = new LuaSkill({
195
+ tools: [new MyTool()]
196
+ });
197
+ ```
198
+
199
+ ---
84
200
 
85
- #### 1. Simple Data Processing Tool
201
+ ## 🛠️ Tool Examples Explained
86
202
 
203
+ ### GetWeatherTool.ts
204
+ **What it does:** Fetches weather for any city using Open-Meteo API (free, no key required)
205
+
206
+ **Learn from this:**
207
+ - External API integration
208
+ - Error handling for API calls
209
+ - Data transformation
210
+
211
+ **Use it for:**
212
+ - Weather information
213
+ - Location-based services
214
+ - External API patterns
215
+
216
+ ---
217
+
218
+ ### UserDataTool.ts
219
+ **What it does:** Gets and updates user data (2 tools)
220
+
221
+ **Learn from this:**
222
+ - Using Platform APIs (`User`)
223
+ - Simple CRUD operations
224
+ - Data retrieval and updates
225
+
226
+ **Use it for:**
227
+ - User profile management
228
+ - Preference storage
229
+ - User-specific data
230
+
231
+ ---
232
+
233
+ ### ProductsTool.ts
234
+ **What it does:** Complete product management (6 tools)
235
+
236
+ **Learn from this:**
237
+ - Full CRUD operations
238
+ - Search functionality
239
+ - Pagination handling
240
+ - Platform API usage
241
+
242
+ **Tools included:**
243
+ - `search_products` - Search catalog
244
+ - `get_all_products` - List with pagination
245
+ - `create_product` - Add new products
246
+ - `update_product` - Modify existing
247
+ - `get_product_by_id` - Get specific product
248
+ - `delete_product` - Remove products
249
+
250
+ **Use it for:**
251
+ - E-commerce catalogs
252
+ - Inventory management
253
+ - Product recommendations
254
+
255
+ ---
256
+
257
+ ### BasketTool.ts
258
+ **What it does:** Shopping cart operations (9 tools)
259
+
260
+ **Learn from this:**
261
+ - Multi-step workflows
262
+ - State management
263
+ - Complex business logic
264
+
265
+ **Tools included:**
266
+ - `create_basket` - Start shopping
267
+ - `get_baskets` - List carts
268
+ - `add_to_basket` - Add items
269
+ - `remove_from_basket` - Remove items
270
+ - `clear_basket` - Empty cart
271
+ - `update_basket_status` - Change status
272
+ - `update_basket_metadata` - Add metadata
273
+ - `checkout_basket` - Convert to order
274
+ - `get_basket_by_id` - Get specific basket
275
+
276
+ **Use it for:**
277
+ - Shopping carts
278
+ - Temporary storage
279
+ - Multi-item collections
280
+
281
+ ---
282
+
283
+ ### OrderTool.ts
284
+ **What it does:** Order creation and tracking (4 tools)
285
+
286
+ **Learn from this:**
287
+ - Order fulfillment flows
288
+ - Status management
289
+ - Basket-to-order conversion
290
+
291
+ **Use it for:**
292
+ - Order processing
293
+ - Purchase completion
294
+ - Order tracking
295
+
296
+ ---
297
+
298
+ ### CustomDataTool.ts
299
+ **What it does:** Movie database with vector search (6 tools)
300
+
301
+ **Learn from this:**
302
+ - **Vector search** - Semantic similarity search
303
+ - Custom data collections
304
+ - Search indexing
305
+ - CRUD on custom schemas
306
+
307
+ **Tools included:**
308
+ - `create_movie` - Add movie with search indexing
309
+ - `get_movies` - List all movies
310
+ - `get_movie_by_id` - Get specific movie
311
+ - `update_movie` - Modify movie data
312
+ - `search_movies` - **Semantic search** (find similar)
313
+ - `delete_movie` - Remove movie
314
+
315
+ **Use it for:**
316
+ - Knowledge bases
317
+ - Document search
318
+ - FAQs
319
+ - Any searchable content
320
+ - Recommendation systems
321
+
322
+ **Vector Search Example:**
87
323
  ```typescript
88
- import { LuaTool } from "lua-cli/skill";
89
- import { z } from "zod";
324
+ // Create with search text
325
+ await Data.create('movies', {
326
+ title: 'Inception',
327
+ director: 'Christopher Nolan'
328
+ }, 'Inception Christopher Nolan sci-fi thriller dreams');
329
+
330
+ // Search semantically
331
+ const results = await Data.search('movies', 'mind-bending thriller', 10, 0.7);
332
+ // Returns: Inception with high similarity score!
333
+ ```
334
+
335
+ ---
336
+
337
+ ### PaymentTool.ts
338
+ **What it does:** Creates payment links (Stripe example)
339
+
340
+ **Learn from this:**
341
+ - Environment variables for API keys
342
+ - External service integration
343
+ - Payment processing
344
+
345
+ **Use it for:**
346
+ - Payment collection
347
+ - Checkout flows
348
+ - Subscription management
349
+
350
+ ---
351
+
352
+ ### CreatePostTool.ts
353
+ **What it does:** Simple example tool
354
+
355
+ **Learn from this:**
356
+ - Basic tool structure
357
+ - Minimal implementation
358
+ - Good starting point
90
359
 
91
- export default class ProcessDataTool implements LuaTool<z.ZodObject<any>, z.ZodObject<any>> {
92
- name = "process_data";
93
- description = "Process and transform input data";
360
+ ---
361
+
362
+ ## 🎨 Customization Guide
363
+
364
+ ### Scenario 1: Keep Only What You Need
365
+
366
+ **If you only need products:**
367
+
368
+ 1. **Update `src/index.ts`:**
369
+ ```typescript
370
+ import { LuaSkill } from "lua-cli";
371
+ import { SearchProductsTool, CreateProductTool } from "./tools/ProductsTool";
372
+
373
+ const productSkill = new LuaSkill({
374
+ name: "product-catalog-skill",
375
+ version: "1.0.0",
376
+ description: "Product search and management",
377
+ context: "Use search_products to find items. Use create_product to add new items.",
378
+ tools: [
379
+ new SearchProductsTool(),
380
+ new CreateProductTool()
381
+ ]
382
+ });
383
+ ```
384
+
385
+ 2. **Delete unused tool files:**
386
+ ```bash
387
+ rm src/tools/BasketTool.ts
388
+ rm src/tools/OrderTool.ts
389
+ rm src/tools/CustomDataTool.ts
390
+ # Keep only ProductsTool.ts
391
+ ```
392
+
393
+ 3. **Test:**
394
+ ```bash
395
+ lua test
396
+ ```
397
+
398
+ ---
399
+
400
+ ### Scenario 2: Build a Restaurant Skill
401
+
402
+ 1. **Rename tools to match your domain:**
403
+
404
+ Rename `CustomDataTool.ts` → `MenuTool.ts`
405
+
406
+ 2. **Update tool names and descriptions:**
407
+ ```typescript
408
+ export class CreateMenuItemTool implements LuaTool {
409
+ name = "create_menu_item";
410
+ description = "Add a new item to the restaurant menu";
94
411
 
95
412
  inputSchema = z.object({
96
- data: z.string().describe("Raw data to process"),
97
- format: z.enum(["json", "xml", "csv"]).describe("Output format")
413
+ name: z.string(),
414
+ category: z.enum(['appetizers', 'mains', 'desserts', 'drinks']),
415
+ price: z.number(),
416
+ description: z.string()
98
417
  });
99
-
100
- outputSchema = z.object({
101
- processedData: z.string(),
102
- format: z.string(),
103
- timestamp: z.string()
104
- });
105
-
106
- async execute(input) {
107
- // Process the data based on format
108
- let processedData;
109
- switch (input.format) {
110
- case "json":
111
- processedData = JSON.stringify({ data: input.data });
112
- break;
113
- case "xml":
114
- processedData = `<data>${input.data}</data>`;
115
- break;
116
- case "csv":
117
- processedData = `data\n"${input.data}"`;
118
- break;
119
- }
120
-
121
- return {
122
- processedData,
123
- format: input.format,
124
- timestamp: new Date().toISOString()
125
- };
418
+
419
+ async execute(input: any) {
420
+ const searchText = `${input.name} ${input.category} ${input.description}`;
421
+ return await Data.create('menu_items', input, searchText);
126
422
  }
127
423
  }
128
424
  ```
129
425
 
130
- #### 2. HTTP API Tool
426
+ 3. **Update skill context:**
427
+ ```typescript
428
+ const restaurantSkill = new LuaSkill({
429
+ description: "Restaurant assistant for menu, orders, and reservations",
430
+ context: `
431
+ Help customers interact with the restaurant.
432
+
433
+ - Use show_menu when asked about food or drinks
434
+ - Use create_order when taking orders (confirm items first)
435
+ - Use make_reservation for table bookings
436
+
437
+ Always mention daily specials.
438
+ Confirm order details before submitting.
439
+ `,
440
+ tools: [new ShowMenuTool(), new CreateOrderTool()]
441
+ });
442
+ ```
443
+
444
+ ---
445
+
446
+ ### Scenario 3: Build a CRM Skill
131
447
 
448
+ 1. **Create customer management tools:**
449
+
450
+ Create `src/tools/CustomerTool.ts`:
132
451
  ```typescript
133
- import { LuaTool } from "lua-cli/skill";
452
+ import { LuaTool, Data } from "lua-cli";
134
453
  import { z } from "zod";
135
- import axios from "axios";
136
454
 
137
- export default class ApiCallTool implements LuaTool<z.ZodObject<any>, z.ZodObject<any>> {
138
- name = "api_call";
139
- description = "Make HTTP API calls";
455
+ export class CreateCustomerTool implements LuaTool {
456
+ name = "create_customer";
457
+ description = "Add a new customer to CRM";
140
458
 
141
459
  inputSchema = z.object({
142
- url: z.string().url().describe("API endpoint URL"),
143
- method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe("HTTP method"),
144
- data: z.any().optional().describe("Request body data"),
145
- headers: z.record(z.string()).optional().describe("Custom headers")
146
- });
147
-
148
- outputSchema = z.object({
149
- status: z.number(),
150
- data: z.any(),
151
- success: z.boolean(),
152
- error: z.string().optional()
460
+ name: z.string(),
461
+ email: z.string().email(),
462
+ company: z.string().optional(),
463
+ phone: z.string().optional()
153
464
  });
154
-
155
- async execute(input) {
156
- try {
157
- const response = await axios({
158
- url: input.url,
159
- method: input.method,
160
- data: input.data,
161
- headers: input.headers || {}
162
- });
163
-
164
- return {
165
- status: response.status,
166
- data: response.data,
167
- success: true
168
- };
169
- } catch (error: any) {
170
- return {
171
- status: error.response?.status || 0,
172
- data: null,
173
- success: false,
174
- error: error.message
175
- };
176
- }
465
+
466
+ async execute(input: any) {
467
+ const searchText = `${input.name} ${input.email} ${input.company || ''}`;
468
+
469
+ const customer = await Data.create('customers', {
470
+ ...input,
471
+ status: 'active',
472
+ createdAt: new Date().toISOString()
473
+ }, searchText);
474
+
475
+ return {
476
+ customerId: customer.id,
477
+ message: `Customer ${input.name} added to CRM`
478
+ };
479
+ }
480
+ }
481
+
482
+ export class SearchCustomersTool implements LuaTool {
483
+ name = "search_customers";
484
+ description = "Search customers by name, email, or company";
485
+ inputSchema = z.object({ query: z.string() });
486
+
487
+ async execute(input: any) {
488
+ const results = await Data.search('customers', input.query, 10, 0.7);
489
+
490
+ return {
491
+ customers: results.data.map(entry => ({
492
+ id: entry.id,
493
+ ...entry.data,
494
+ relevance: entry.score
495
+ }))
496
+ };
177
497
  }
178
498
  }
179
499
  ```
180
500
 
181
- #### 3. File Operations Tool
501
+ 2. **Create interaction tracking:**
182
502
 
183
503
  ```typescript
184
- import { LuaTool } from "lua-cli/skill";
185
- import { z } from "zod";
186
- import fs from "fs/promises";
187
- import path from "path";
188
-
189
- export default class FileTool implements LuaTool<z.ZodObject<any>, z.ZodObject<any>> {
190
- name = "file_operations";
191
- description = "Perform file system operations";
504
+ export class LogInteractionTool implements LuaTool {
505
+ name = "log_interaction";
506
+ description = "Log customer interaction";
192
507
 
193
508
  inputSchema = z.object({
194
- operation: z.enum(["read", "write", "list", "delete"]).describe("File operation to perform"),
195
- path: z.string().describe("File or directory path"),
196
- content: z.string().optional().describe("Content to write (for write operations)")
197
- });
198
-
199
- outputSchema = z.object({
200
- success: z.boolean(),
201
- data: z.any().optional(),
202
- error: z.string().optional()
509
+ customerId: z.string(),
510
+ type: z.enum(['call', 'email', 'meeting']),
511
+ notes: z.string()
203
512
  });
204
-
205
- async execute(input) {
206
- try {
207
- switch (input.operation) {
208
- case "read":
209
- const content = await fs.readFile(input.path, "utf8");
210
- return { success: true, data: content };
211
-
212
- case "write":
213
- await fs.writeFile(input.path, input.content || "");
214
- return { success: true, data: "File written successfully" };
215
-
216
- case "list":
217
- const files = await fs.readdir(input.path);
218
- return { success: true, data: files };
219
-
220
- case "delete":
221
- await fs.unlink(input.path);
222
- return { success: true, data: "File deleted successfully" };
223
-
224
- default:
225
- return { success: false, error: "Invalid operation" };
226
- }
227
- } catch (error: any) {
228
- return { success: false, error: error.message };
229
- }
513
+
514
+ async execute(input: any) {
515
+ await Data.create('interactions', {
516
+ customerId: input.customerId,
517
+ type: input.type,
518
+ notes: input.notes,
519
+ timestamp: new Date().toISOString()
520
+ }, `${input.type} ${input.notes}`);
521
+
522
+ return { success: true };
230
523
  }
231
524
  }
232
525
  ```
233
526
 
234
- ## 🔧 Creating Services
527
+ ---
235
528
 
236
- Services provide reusable functionality across multiple tools:
529
+ ## 🔧 Development Commands
237
530
 
238
- ```typescript
239
- // services/DatabaseService.ts
240
- import axios from "axios";
531
+ ```bash
532
+ # Install dependencies
533
+ npm install
241
534
 
242
- export default class DatabaseService {
243
- private baseUrl: string;
244
-
245
- constructor(baseUrl: string) {
246
- this.baseUrl = baseUrl;
247
- }
248
-
249
- async query(sql: string) {
250
- const response = await axios.post(`${this.baseUrl}/query`, { sql });
251
- return response.data;
252
- }
253
-
254
- async insert(table: string, data: any) {
255
- const response = await axios.post(`${this.baseUrl}/insert`, { table, data });
256
- return response.data;
257
- }
258
- }
535
+ # Test tools interactively
536
+ npm run test
537
+ # or
538
+ lua test
539
+
540
+ # Start development mode
541
+ npm run dev
542
+ # or
543
+ lua dev
544
+
545
+ # Compile skill
546
+ npm run compile
547
+ # or
548
+ lua compile
549
+
550
+ # Push to server
551
+ npm run push
552
+ # or
553
+ lua push
554
+
555
+ # Deploy to production
556
+ lua deploy
259
557
  ```
260
558
 
261
- ## 📝 Main Skill Definition
559
+ ---
262
560
 
263
- Your `index.ts` file defines the skill and registers tools:
561
+ ## 📝 Configuration Files
264
562
 
265
- ```typescript
266
- import { LuaSkill } from "lua-cli/skill";
267
- import ProcessDataTool from "./tools/ProcessDataTool";
268
- import ApiCallTool from "./tools/ApiCallTool";
269
- import FileTool from "./tools/FileTool";
270
-
271
- // Initialize skill
272
- const skill = new LuaSkill();
273
-
274
- // Add tools
275
- skill.addTool(new ProcessDataTool());
276
- skill.addTool(new ApiCallTool());
277
- skill.addTool(new FileTool());
278
-
279
- // Test cases (optional)
280
- const testCases = [
281
- { tool: "process_data", data: "Hello World", format: "json" },
282
- { tool: "api_call", url: "https://httpbin.org/get", method: "GET" },
283
- { tool: "file_operations", operation: "list", path: "./" }
284
- ];
285
-
286
- async function runTests() {
287
- console.log("🧪 Running tool tests...\n");
288
-
289
- for (const [index, testCase] of testCases.entries()) {
290
- try {
291
- console.log(`Test ${index + 1}: ${testCase.tool}`);
292
- const result = await skill.run(testCase);
293
- console.log("✅ Success:", result);
294
- } catch (error: any) {
295
- console.log("❌ Error:", error.message);
296
- }
297
- console.log("");
298
- }
299
- }
563
+ ### `lua.skill.yaml`
300
564
 
301
- // Run tests if this file is executed directly
302
- if (import.meta.url === `file://${process.argv[1]}`) {
303
- runTests().catch(console.error);
304
- }
565
+ Auto-managed configuration file. Contains:
566
+ - Agent ID and organization ID
567
+ - Skill IDs (auto-created during compilation)
568
+ - Optional environment variables
569
+
570
+ ```yaml
571
+ agent:
572
+ agentId: agent_abc123
573
+ orgId: org_xyz789
574
+
575
+ skills:
576
+ - name: my-skill
577
+ version: 1.0.0
578
+ skillId: skill_xyz789 # Auto-created
305
579
  ```
306
580
 
307
- ## 🎯 Best Practices
581
+ **Don't manually edit `skillId`** - it's auto-managed!
308
582
 
309
- ### 1. Input Validation
310
- Always use Zod schemas for robust input validation:
583
+ ---
311
584
 
312
- ```typescript
313
- inputSchema = z.object({
314
- email: z.string().email().describe("Valid email address"),
315
- age: z.number().min(0).max(120).describe("Age between 0 and 120"),
316
- tags: z.array(z.string()).optional().describe("Optional array of tags")
317
- });
585
+ ### `.env` File
586
+
587
+ Create `.env` for environment variables:
588
+
589
+ ```bash
590
+ # External API Keys
591
+ STRIPE_API_KEY=sk_test_abc123
592
+ SENDGRID_API_KEY=SG.xyz789
593
+ OPENAI_API_KEY=sk-abc123
594
+
595
+ # Configuration
596
+ API_BASE_URL=https://api.example.com
597
+ ENABLE_DEBUG=false
318
598
  ```
319
599
 
320
- ### 2. Error Handling
321
- Provide meaningful error messages:
600
+ **Remember:** Add `.env` to `.gitignore`!
322
601
 
323
- ```typescript
324
- async execute(input) {
325
- try {
326
- // Your logic here
327
- return { success: true, data: result };
328
- } catch (error: any) {
329
- return {
330
- success: false,
331
- error: error.message,
332
- timestamp: new Date().toISOString()
333
- };
602
+ ---
603
+
604
+ ### `package.json`
605
+
606
+ Contains your dependencies and scripts:
607
+
608
+ ```json
609
+ {
610
+ "name": "your-skill-name",
611
+ "version": "1.0.0",
612
+ "scripts": {
613
+ "test": "lua test",
614
+ "dev": "lua dev",
615
+ "compile": "lua compile",
616
+ "push": "lua push"
617
+ },
618
+ "dependencies": {
619
+ "lua-cli": "^2.0.0",
620
+ "zod": "^3.0.0"
334
621
  }
335
622
  }
336
623
  ```
337
624
 
338
- ### 3. Async Operations
339
- Use async/await for better error handling:
625
+ ---
340
626
 
341
- ```typescript
342
- async execute(input) {
343
- const result = await someAsyncOperation(input);
344
- return result;
345
- }
627
+ ## 🎯 Next Steps
628
+
629
+ ### 1. Explore the Examples
630
+
631
+ **Try each tool:**
632
+ ```bash
633
+ lua test
634
+ ```
635
+
636
+ - Test `get_weather` - See external API calls
637
+ - Test `search_products` - See platform API usage
638
+ - Test `search_movies` - See vector search
639
+ - Test `create_basket` → `add_to_basket` → `checkout_basket` - See workflows
640
+
641
+ ---
642
+
643
+ ### 2. Understand the Code
644
+
645
+ **Read the tool files** in `src/tools/`:
646
+ - Start with simple ones (`GetWeatherTool.ts`, `CreatePostTool.ts`)
647
+ - Then explore complex ones (`BasketTool.ts`, `ProductsTool.ts`)
648
+ - Study vector search (`CustomDataTool.ts`)
649
+
650
+ **Key files to understand:**
651
+ - `src/index.ts` - How skills are structured
652
+ - `src/tools/ProductsTool.ts` - Complete CRUD pattern
653
+ - `src/tools/CustomDataTool.ts` - Vector search pattern
654
+ - `src/tools/BasketTool.ts` - Multi-step workflow pattern
655
+
656
+ ---
657
+
658
+ ### 3. Make It Yours
659
+
660
+ **Choose your approach:**
661
+
662
+ #### A. Modify Examples
663
+ Keep examples, change them to your domain:
664
+ - Movies → Your data type
665
+ - Products → Your catalog
666
+ - Weather → Your external API
667
+
668
+ #### B. Start Fresh
669
+ Delete examples, create new tools:
670
+ ```bash
671
+ rm src/tools/*.ts
672
+ touch src/tools/MyFirstTool.ts
673
+ ```
674
+
675
+ #### C. Mix and Match
676
+ Keep useful examples, add custom tools:
677
+ - Keep: `UserDataTool.ts` (always useful)
678
+ - Keep: `CustomDataTool.ts` (for knowledge base)
679
+ - Remove: `BasketTool.ts` (if not e-commerce)
680
+ - Add: Your custom tools
681
+
682
+ ---
683
+
684
+ ### 4. Deploy
685
+
686
+ ```bash
687
+ # Test thoroughly
688
+ lua test
689
+ lua dev
690
+
691
+ # Push to server
692
+ lua push
693
+
694
+ # Deploy to production
695
+ lua deploy
696
+ ```
697
+
698
+ ---
699
+
700
+ ## 📚 Documentation
701
+
702
+ ### In This Project
703
+ - **README.md** - This file (project overview)
704
+ - **QUICKSTART.md** - 5-minute start guide
705
+ - **TOOL_EXAMPLES.md** - Detailed tool explanations
706
+
707
+ ### Lua CLI Documentation
708
+ - **Getting Started** - Complete tutorial
709
+ - **API Reference** - All platform APIs
710
+ - **CLI Reference** - All commands
711
+ - **Template Guide** - This template explained
712
+
713
+ **Access via:**
714
+ ```bash
715
+ # In your node_modules
716
+ ls node_modules/lua-cli/*.md
717
+
718
+ # Or online
719
+ https://docs.lua.ai
346
720
  ```
347
721
 
348
- ### 4. Service Reuse
349
- Extract common functionality into services:
722
+ ---
723
+
724
+ ## 💡 Tips & Tricks
725
+
726
+ ### Tip 1: Start with Dev Mode
727
+
728
+ ```bash
729
+ lua dev
730
+ ```
731
+
732
+ **Why?**
733
+ - Instant feedback
734
+ - Chat testing
735
+ - Live reload
736
+ - See what the AI actually does
737
+
738
+ ---
739
+
740
+ ### Tip 2: Use Vector Search
350
741
 
742
+ For any searchable content:
351
743
  ```typescript
352
- // In your tool
353
- import DatabaseService from "../services/DatabaseService";
744
+ // When creating
745
+ await Data.create('items', data, searchableText);
354
746
 
355
- export default class UserTool {
356
- private dbService = new DatabaseService("http://localhost:3000");
747
+ // When searching
748
+ const results = await Data.search('items', query, 10, 0.7);
749
+ ```
750
+
751
+ **Great for:**
752
+ - FAQs
753
+ - Documentation
754
+ - Product descriptions
755
+ - Customer notes
756
+
757
+ ---
758
+
759
+ ### Tip 3: Write Good Context
760
+
761
+ The `context` field is critical - it guides the AI:
762
+
763
+ **✅ Good:**
764
+ ```typescript
765
+ context: `
766
+ This skill helps users find and purchase products.
357
767
 
358
- async execute(input) {
359
- const users = await this.dbService.query("SELECT * FROM users");
360
- return { users };
361
- }
362
- }
768
+ - Use search_products when users describe what they want
769
+ - Use create_basket to start a new shopping session
770
+ - Use add_to_basket when they want to buy something
771
+ - Use checkout_basket to complete the purchase
772
+
773
+ Always confirm items and total before checkout.
774
+ Mention shipping options during checkout.
775
+ `
363
776
  ```
364
777
 
365
- ## 📦 Dependencies
778
+ **❌ Bad:**
779
+ ```typescript
780
+ context: "Product and shopping tools"
781
+ ```
366
782
 
367
- Add external dependencies to your `package.json`:
783
+ ---
368
784
 
369
- ```json
370
- {
371
- "dependencies": {
372
- "axios": "^1.6.0",
373
- "zod": "^3.22.0"
374
- }
375
- }
785
+ ### Tip 4: Test with Real Scenarios
786
+
787
+ Don't just test with perfect inputs:
788
+
789
+ ```bash
790
+ lua dev
376
791
  ```
377
792
 
378
- The Lua CLI will automatically bundle these dependencies when you run `lua compile`.
793
+ **Try:**
794
+ - ✅ "What's the weather?" (missing city - should prompt)
795
+ - ✅ "Add laptop to cart" (need basket ID - should create)
796
+ - ✅ "XYZ" (nonsense - should handle gracefully)
797
+
798
+ ---
379
799
 
380
- ## 🧪 Testing
800
+ ### Tip 5: Use Environment Variables
381
801
 
382
- ### Interactive Testing
802
+ **Never hardcode secrets:**
803
+
804
+ ```typescript
805
+ // ❌ Bad
806
+ const apiKey = 'sk_abc123';
807
+
808
+ // ✅ Good
809
+ import { env } from 'lua-cli';
810
+ const apiKey = env('STRIPE_API_KEY');
811
+ ```
812
+
813
+ Create `.env`:
383
814
  ```bash
384
- lua test
815
+ STRIPE_API_KEY=your_key_here
385
816
  ```
386
817
 
387
- ### Programmatic Testing
818
+ ---
819
+
820
+ ## 🎨 Customization Recipes
821
+
822
+ ### Recipe 1: Simple Weather Skill
823
+
388
824
  ```typescript
389
- const result = await skill.run({
390
- tool: "my_tool",
391
- param1: "value1",
392
- param2: 42
825
+ // src/index.ts
826
+ import { LuaSkill } from "lua-cli";
827
+ import GetWeatherTool from "./tools/GetWeatherTool";
828
+
829
+ const weatherSkill = new LuaSkill({
830
+ name: "weather-skill",
831
+ version: "1.0.0",
832
+ description: "Provides weather information worldwide",
833
+ context: "Use get_weather when users ask about weather or temperature. Always include the city name.",
834
+ tools: [new GetWeatherTool()]
393
835
  });
394
- console.log(result);
395
836
  ```
396
837
 
397
- ## 🚀 Deployment
838
+ **Deploy:**
839
+ ```bash
840
+ lua test # Test it
841
+ lua push # Upload
842
+ lua deploy # Go live
843
+ ```
844
+
845
+ ---
846
+
847
+ ### Recipe 2: Knowledge Base Skill
848
+
849
+ Use CustomDataTool.ts as template:
850
+
851
+ 1. Rename collections: `movies` → `articles`
852
+ 2. Update fields: title, director → title, content, category
853
+ 3. Update descriptions to match your domain
854
+ 4. Update skill context
855
+
856
+ **Result:** Searchable knowledge base!
857
+
858
+ ---
859
+
860
+ ### Recipe 3: E-commerce Skill
861
+
862
+ Keep: `ProductsTool.ts`, `BasketTool.ts`, `OrderTool.ts`
863
+
864
+ Remove: Everything else
865
+
866
+ **Result:** Complete shopping experience!
867
+
868
+ ---
869
+
870
+ ## 🔍 Understanding Multi-Skill Projects
871
+
872
+ This template has **7 skills** in one project:
873
+
874
+ **Why multiple skills?**
875
+ - Different domains (products vs orders)
876
+ - Different deployment schedules
877
+ - Logical organization
878
+ - Easier to manage
879
+
880
+ **How it works:**
881
+ - Each skill gets its own `skillId` in `lua.skill.yaml`
882
+ - All skills deploy together with `lua push`
883
+ - All skills available to your agent
884
+ - AI chooses right skill automatically
885
+
886
+ **You can:**
887
+ - Keep all 7 (if relevant)
888
+ - Merge into 1 (simpler)
889
+ - Create your own grouping
890
+
891
+ ---
892
+
893
+ ## 📊 Tool Inventory
894
+
895
+ ### Included Tools (30 total)
896
+
897
+ | Category | Count | Examples |
898
+ |----------|-------|----------|
899
+ | **Weather** | 1 | get_weather |
900
+ | **User Data** | 2 | get_user_data, update_user_data |
901
+ | **Products** | 6 | search, create, update, get, delete, get_by_id |
902
+ | **Baskets** | 9 | create, add_item, remove, clear, checkout, etc. |
903
+ | **Orders** | 4 | create, update_status, get, get_by_id |
904
+ | **Custom Data** | 6 | create, search, update, delete (movies example) |
905
+ | **Payment** | 1 | create_payment_link |
906
+ | **Posts** | 1 | create_post |
907
+
908
+ **Total: 30 working examples** covering all major use cases!
909
+
910
+ ---
911
+
912
+ ## 🚨 Common Mistakes to Avoid
913
+
914
+ ### ❌ Mistake 1: Hardcoding API Keys
915
+ ```typescript
916
+ const apiKey = 'sk_abc123'; // DON'T DO THIS
917
+ ```
918
+
919
+ ✅ **Fix:** Use environment variables
920
+ ```typescript
921
+ import { env } from 'lua-cli';
922
+ const apiKey = env('API_KEY');
923
+ ```
398
924
 
399
- Once your skill is ready:
925
+ ---
926
+
927
+ ### ❌ Mistake 2: Unclear Tool Names
928
+ ```typescript
929
+ name = "tool1" // Unclear
930
+ name = "do_stuff" // Too generic
931
+ ```
400
932
 
401
- 1. **Compile:**
402
- ```bash
403
- lua compile
404
- ```
933
+ **Fix:** Be specific
934
+ ```typescript
935
+ name = "search_products"
936
+ name = "create_order"
937
+ name = "get_user_profile"
938
+ ```
405
939
 
406
- 2. **Deploy:**
407
- ```bash
408
- lua deploy
409
- ```
940
+ ---
410
941
 
411
- The compiled skill data will be in `.lua/deploy.json` and can be used with the Lua platform.
942
+ ### Mistake 3: Weak Descriptions
943
+ ```typescript
944
+ description = "Gets data" // Too vague
945
+ ```
412
946
 
413
- ## 📚 API Reference
947
+ **Fix:** Be descriptive
948
+ ```typescript
949
+ description = "Searches product catalog by name, category, or description"
950
+ ```
414
951
 
415
- ### LuaSkill Class
952
+ ---
416
953
 
954
+ ### ❌ Mistake 4: Missing Error Handling
417
955
  ```typescript
418
- class LuaSkill {
419
- constructor()
420
- addTool<TInput, TOutput>(tool: LuaTool<TInput, TOutput>): void
421
- async run(input: Record<string, any>): Promise<any>
956
+ async execute(input: any) {
957
+ const result = await api.call(input);
958
+ return result; // What if it fails?
422
959
  }
423
960
  ```
424
961
 
425
- ### LuaTool Interface
426
-
962
+ **Fix:** Handle errors
427
963
  ```typescript
428
- interface LuaTool<TInput extends ZodType, TOutput extends ZodType> {
429
- name: string;
430
- description: string;
431
- inputSchema: TInput;
432
- outputSchema: TOutput;
433
- execute(input: z.infer<TInput>): Promise<z.infer<TOutput>>;
964
+ async execute(input: any) {
965
+ try {
966
+ const result = await api.call(input);
967
+ if (!result.success) {
968
+ throw new Error(result.error || 'API call failed');
969
+ }
970
+ return result.data;
971
+ } catch (error) {
972
+ throw new Error(`Failed to fetch data: ${error.message}`);
973
+ }
434
974
  }
435
975
  ```
436
976
 
437
- ## 🔍 Troubleshooting
977
+ ---
978
+
979
+ ## 🎓 Learning Path
980
+
981
+ ### Week 1: Learn by Testing
982
+ - ✅ Run `lua test` daily
983
+ - ✅ Try every example tool
984
+ - ✅ Understand inputs and outputs
985
+ - ✅ Read the tool code
986
+
987
+ ### Week 2: Modify Examples
988
+ - ✅ Change descriptions
989
+ - ✅ Add new input fields
990
+ - ✅ Modify return values
991
+ - ✅ Test your changes
992
+
993
+ ### Week 3: Build Your Own
994
+ - ✅ Create 1-2 custom tools
995
+ - ✅ Remove unused examples
996
+ - ✅ Update skill context
997
+ - ✅ Deploy to production
998
+
999
+ ---
1000
+
1001
+ ## 🔗 Resources
1002
+
1003
+ ### Documentation
1004
+ - See markdown files in `node_modules/lua-cli/`
1005
+ - Visit https://docs.lua.ai
1006
+ - Check CLI help: `lua --help`
438
1007
 
439
- ### Common Issues
1008
+ ### Examples
1009
+ - All tools in `src/tools/` are working examples
1010
+ - Copy, modify, learn!
440
1011
 
441
- 1. **"Tool not found" error:**
442
- - Ensure the tool name matches exactly
443
- - Check that the tool is added to the skill
1012
+ ### Community
1013
+ - GitHub: https://github.com/lua-ai/lua-cli
1014
+ - Issues: Report bugs or ask questions
1015
+ - Email: support@lua.ai
444
1016
 
445
- 2. **Input validation errors:**
446
- - Verify your Zod schema matches the input structure
447
- - Check required vs optional fields
1017
+ ---
448
1018
 
449
- 3. **Bundling errors:**
450
- - Ensure all dependencies are in `package.json`
451
- - Check import paths are correct
1019
+ ## Checklist Before Deploying
452
1020
 
453
- 4. **Runtime errors:**
454
- - Use try/catch blocks in your execute methods
455
- - Check that all required globals are available
1021
+ - [ ] Removed unused tools and skills
1022
+ - [ ] Updated skill names and descriptions
1023
+ - [ ] Wrote clear context for AI
1024
+ - [ ] Tested all tools with `lua test`
1025
+ - [ ] Tested conversationally with `lua dev`
1026
+ - [ ] No hardcoded secrets (use `.env`)
1027
+ - [ ] Updated version number
1028
+ - [ ] Reviewed error messages
1029
+ - [ ] Checked tool names (no spaces!)
456
1030
 
457
- ### Debug Tips
1031
+ ---
458
1032
 
459
- - Use `console.log` for debugging (output appears in test mode)
460
- - Test individual tools before adding to the skill
461
- - Validate schemas with Zod's `.parse()` method
462
- - Check the generated `.lua/deploy.json` for compilation issues
1033
+ ## 🎉 You're Ready!
463
1034
 
464
- ## 📖 Examples
1035
+ This template gives you:
1036
+ - ✅ **30 working tools** to learn from
1037
+ - ✅ **All API patterns** demonstrated
1038
+ - ✅ **Production-ready** structure
1039
+ - ✅ **Easy to customize** for your needs
465
1040
 
466
- See the `tools/` directory for complete working examples:
467
- - `GetWeatherTool.ts` - Simple API call
468
- - `GetUserDataTool.ts` - Complex service integration
469
- - `CreatePostTool.ts` - POST request with data
1041
+ **Next steps:**
1042
+ 1. Test the examples: `lua test`
1043
+ 2. Chat with the AI: `lua dev`
1044
+ 3. Make it yours: Edit tools and skills
1045
+ 4. Deploy: `lua push && lua deploy`
470
1046
 
471
- ## 🤝 Contributing
1047
+ **Go build something amazing!** 🚀
472
1048
 
473
- Found a bug or want to add a feature? Check out our [contributing guidelines](../../CONTRIBUTING.md).
1049
+ ---
474
1050
 
475
- ## 📄 License
1051
+ **Quick Links:**
1052
+ - 📘 [Quick Start](QUICKSTART.md) - 5-minute guide
1053
+ - 🔧 [Tool Examples](TOOL_EXAMPLES.md) - Detailed tool docs
1054
+ - 💻 [CLI Commands](../CLI_REFERENCE.md) - Command reference
1055
+ - 📚 [API Docs](../API_REFERENCE.md) - Complete API reference
476
1056
 
477
- This template is part of the Lua CLI framework. See the main [LICENSE](../../LICENSE) file for details.