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.
Files changed (191) 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 +45 -0
  7. package/dist/api/agent.api.service.js +57 -0
  8. package/dist/api/auth.api.service.d.ts +48 -0
  9. package/dist/api/auth.api.service.js +54 -0
  10. package/dist/api/basket.api.service.d.ts +85 -0
  11. package/dist/api/basket.api.service.js +164 -0
  12. package/dist/api/chat.api.service.d.ts +21 -0
  13. package/dist/api/chat.api.service.js +24 -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 +69 -0
  17. package/dist/api/custom.data.api.service.js +125 -0
  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 +53 -0
  21. package/dist/api/order.api.service.js +95 -0
  22. package/dist/api/products.api.service.d.ts +66 -0
  23. package/dist/api/products.api.service.js +112 -0
  24. package/dist/api/skills.api.service.d.ts +77 -0
  25. package/dist/api/skills.api.service.js +88 -0
  26. package/dist/api/tool.api.service.d.ts +52 -0
  27. package/dist/api/tool.api.service.js +73 -0
  28. package/dist/api/user.data.api.service.d.ts +33 -0
  29. package/dist/api/user.data.api.service.js +59 -0
  30. package/dist/api-exports.d.ts +271 -0
  31. package/dist/api-exports.js +372 -0
  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 -873
  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 +78 -0
  55. package/dist/common/basket.instance.js +132 -0
  56. package/dist/common/data.entry.instance.d.ts +39 -0
  57. package/dist/common/data.entry.instance.js +76 -0
  58. package/dist/common/http.client.d.ts +64 -0
  59. package/dist/common/http.client.js +133 -0
  60. package/dist/common/order.instance.d.ts +40 -0
  61. package/dist/common/order.instance.js +79 -0
  62. package/dist/common/product.instance.d.ts +33 -0
  63. package/dist/common/product.instance.js +63 -0
  64. package/dist/common/product.pagination.instance.d.ts +43 -0
  65. package/dist/common/product.pagination.instance.js +74 -0
  66. package/dist/common/product.search.instance.d.ts +22 -0
  67. package/dist/common/product.search.instance.js +40 -0
  68. package/dist/common/user.instance.d.ts +41 -0
  69. package/dist/common/user.instance.js +84 -0
  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 +101 -0
  83. package/dist/interfaces/admin.js +5 -0
  84. package/dist/interfaces/agent.d.ts +107 -0
  85. package/dist/interfaces/agent.js +5 -0
  86. package/dist/interfaces/baskets.d.ts +135 -0
  87. package/dist/interfaces/baskets.js +19 -0
  88. package/dist/interfaces/chat.d.ts +61 -0
  89. package/dist/interfaces/chat.js +5 -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 +82 -0
  95. package/dist/interfaces/custom.data.js +5 -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 +91 -0
  103. package/dist/interfaces/orders.js +19 -0
  104. package/dist/interfaces/product.d.ts +65 -0
  105. package/dist/interfaces/product.js +5 -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 -85
  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 -19
  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 -118
  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 +11 -12
  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 +3781 -0
  170. package/template/package.json +1 -1
  171. package/template/src/index.ts +81 -40
  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 -27
  178. package/dist/custom-data-api.d.ts +0 -72
  179. package/dist/custom-data-api.js +0 -174
  180. package/dist/product-api.d.ts +0 -197
  181. package/dist/product-api.js +0 -152
  182. package/dist/services/api.d.ts +0 -569
  183. package/dist/services/api.js +0 -625
  184. package/dist/skill.d.ts +0 -50
  185. package/dist/types.d.ts +0 -1
  186. package/dist/types.js +0 -2
  187. package/dist/user-data-api.d.ts +0 -39
  188. package/dist/user-data-api.js +0 -50
  189. package/template/API.md +0 -604
  190. package/template/DEVELOPER.md +0 -771
  191. package/template/lua.skill.yaml +0 -16
@@ -0,0 +1,818 @@
1
+ # Lua CLI - Command Reference
2
+
3
+ Complete reference guide for all Lua CLI commands.
4
+
5
+ ---
6
+
7
+ ## 📋 Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quick Start](#quick-start)
11
+ - [Authentication Commands](#authentication-commands)
12
+ - [Skill Management Commands](#skill-management-commands)
13
+ - [Command Reference](#command-reference)
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install -g lua-cli
21
+ ```
22
+
23
+ Or use with npx (no installation required):
24
+ ```bash
25
+ npx lua-cli [command]
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ # 1. Authenticate
34
+ lua auth configure
35
+
36
+ # 2. Initialize a new skill project
37
+ mkdir my-skill && cd my-skill
38
+ lua init
39
+
40
+ # 3. Test your skill locally
41
+ lua test
42
+
43
+ # 4. Push to development environment
44
+ lua push
45
+
46
+ # 5. Start development mode with live reload
47
+ lua dev
48
+
49
+ # 6. Deploy to production
50
+ lua deploy
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Authentication Commands
56
+
57
+ ### `lua auth configure`
58
+
59
+ Sets up your Lua CLI authentication credentials.
60
+
61
+ **Usage:**
62
+ ```bash
63
+ lua auth configure
64
+ ```
65
+
66
+ **Interactive Prompts:**
67
+ 1. Choose authentication method:
68
+ - **API Key**: Enter an existing API key
69
+ - **Email**: Get API key via email OTP
70
+
71
+ **For API Key Method:**
72
+ - Prompts for your API key
73
+ - Validates the key with the server
74
+ - Stores securely in system keychain
75
+
76
+ **For Email Method:**
77
+ - Prompts for email address
78
+ - Sends 6-digit OTP code to your email
79
+ - Allows 3 attempts to enter correct OTP
80
+ - Automatically generates and saves API key
81
+
82
+ **Storage:**
83
+ - Credentials stored in system keychain
84
+ - macOS: Keychain
85
+ - Windows: Credential Vault
86
+ - Linux: libsecret
87
+
88
+ **Example:**
89
+ ```bash
90
+ $ lua auth configure
91
+ ? Choose authentication method: Email
92
+ ? Enter your email address: you@example.com
93
+ 📧 Sending OTP to your email...
94
+ ✅ OTP sent successfully!
95
+ ? Enter the OTP code: 123456
96
+ 🔐 Verifying OTP...
97
+ ✅ OTP verified successfully!
98
+ 🔑 Generating API key...
99
+ ✅ API key generated and saved securely.
100
+ ```
101
+
102
+ ---
103
+
104
+ ### `lua auth key`
105
+
106
+ Displays your stored API key.
107
+
108
+ **Usage:**
109
+ ```bash
110
+ lua auth key
111
+ ```
112
+
113
+ **Interactive Prompts:**
114
+ - Confirmation prompt before displaying (security)
115
+
116
+ **Output:**
117
+ ```bash
118
+ $ lua auth key
119
+ ? This will display your API key. Are you sure you want to continue? Yes
120
+ 🔑 Your API key:
121
+ lsk_abc123def456...
122
+ ```
123
+
124
+ **Security Note:** Only displays after explicit confirmation to prevent accidental exposure.
125
+
126
+ ---
127
+
128
+ ### `lua auth logout`
129
+
130
+ Deletes your stored API key from the system.
131
+
132
+ **Usage:**
133
+ ```bash
134
+ lua auth logout
135
+ ```
136
+
137
+ **Interactive Prompts:**
138
+ - Confirmation prompt (action cannot be undone)
139
+
140
+ **What it does:**
141
+ - Removes API key from system keychain
142
+ - Does NOT invalidate the key on the server
143
+ - You'll need to run `lua auth configure` again to use the CLI
144
+
145
+ **Example:**
146
+ ```bash
147
+ $ lua auth logout
148
+ ? Are you sure you want to delete your API key? This action cannot be undone. Yes
149
+ ✅ API key deleted successfully.
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Skill Management Commands
155
+
156
+ ### `lua init`
157
+
158
+ Initializes a new Lua skill project in the current directory.
159
+
160
+ **Usage:**
161
+ ```bash
162
+ mkdir my-skill && cd my-skill
163
+ lua init
164
+ ```
165
+
166
+ **Interactive Prompts:**
167
+
168
+ **Step 1: Choose Agent**
169
+ - **Select existing agent**: Choose from your organizations and agents
170
+ - **Create new agent**: Create a new AI agent
171
+
172
+ **Step 2a: For Existing Agent**
173
+ - Select organization
174
+ - Select agent from organization
175
+
176
+ **Step 2b: For New Agent**
177
+ - Enter business name (default: "Private")
178
+ - Enter agent name (required)
179
+ - Select business type from list
180
+ - Select brand personality
181
+ - Enter brand traits (optional)
182
+ - Configure features (enable/disable)
183
+
184
+ **What it creates:**
185
+ ```
186
+ my-skill/
187
+ ├── src/
188
+ │ ├── index.ts # Skill entry point
189
+ │ ├── tools/ # Tool implementations
190
+ │ │ ├── GetWeatherTool.ts
191
+ │ │ ├── UserDataTool.ts
192
+ │ │ ├── ProductsTool.ts
193
+ │ │ └── ... (more examples)
194
+ │ └── services/ # Helper services
195
+ ├── lua.skill.yaml # Skill configuration
196
+ ├── package.json # Dependencies
197
+ ├── tsconfig.json # TypeScript config
198
+ ├── .env.example # Environment variables template
199
+ └── README.md # Project documentation
200
+ ```
201
+
202
+ **Configuration File (`lua.skill.yaml`):**
203
+ ```yaml
204
+ agent:
205
+ agentId: agent_abc123
206
+ orgId: org_xyz789
207
+ persona: "..."
208
+ welcomeMessage: "..."
209
+
210
+ skills: [] # Auto-populated during compilation
211
+ ```
212
+
213
+ **Example:**
214
+ ```bash
215
+ $ lua init
216
+ ? What would you like to do? Create new agent
217
+ ? Enter business name: My Coffee Shop
218
+ ? Enter agent name: CoffeeBot
219
+ ? Select business type: Food & Beverage (e.g. restaurant, bakery)
220
+ ? Select brand personality: Friendly
221
+ ? Enter brand traits: Warm, welcoming, knowledgeable about coffee
222
+ 🔄 Creating agent...
223
+ ✅ Agent created successfully!
224
+ ⏳ Waiting for agent to be ready...
225
+ ✅ Created lua.skill.yaml
226
+ ✅ Copied template files
227
+ 📦 Installing dependencies...
228
+ ✅ Lua skill project initialized successfully!
229
+ ```
230
+
231
+ ---
232
+
233
+ ### `lua compile`
234
+
235
+ Compiles your TypeScript skill into deployable JavaScript bundles.
236
+
237
+ **Usage:**
238
+ ```bash
239
+ lua compile
240
+ ```
241
+
242
+ **What it does:**
243
+ 1. Analyzes your TypeScript code to detect tools
244
+ 2. Bundles each tool individually with esbuild
245
+ 3. Bundles the main index file
246
+ 4. Extracts tool metadata and schemas
247
+ 5. Creates deployment artifacts
248
+ 6. Automatically creates skills via API if needed
249
+
250
+ **Output:**
251
+ ```
252
+ dist/
253
+ ├── deployment.json # Deployment metadata
254
+ ├── index.js # Main skill bundle
255
+ └── tools/ # Individual tool bundles
256
+ ├── GetWeatherTool.js
257
+ ├── UserDataTool.js
258
+ └── ...
259
+
260
+ .lua/
261
+ ├── deploy.json # Legacy format
262
+ ├── get_weather.js # Uncompressed (for debugging)
263
+ └── ...
264
+ ```
265
+
266
+ **Example:**
267
+ ```bash
268
+ $ lua compile
269
+ 🔨 Compiling Lua skill...
270
+ 📦 Found 15 tools to bundle...
271
+ 📦 Bundling GetWeatherTool...
272
+ 📦 Bundling UserDataTool...
273
+ ... (more tools)
274
+ 📦 Bundling main index...
275
+ ✅ Skill compiled successfully - 15 tools bundled
276
+ ```
277
+
278
+ **Notes:**
279
+ - Automatically detects tools from `new LuaSkill({ tools: [...] })`
280
+ - Automatically detects tools from `skill.addTools([...])`
281
+ - Creates skills in `lua.skill.yaml` if they don't exist
282
+ - Updates existing skills with new tools
283
+
284
+ ---
285
+
286
+ ### `lua test`
287
+
288
+ Tests individual tools locally in a sandboxed environment.
289
+
290
+ **Usage:**
291
+ ```bash
292
+ lua test
293
+ ```
294
+
295
+ **Interactive Prompts:**
296
+ 1. Select a tool from the list
297
+ 2. Enter input values based on the tool's schema
298
+ 3. View execution results
299
+
300
+ **What it does:**
301
+ 1. Compiles the skill
302
+ 2. Lists all available tools
303
+ 3. Prompts for tool selection
304
+ 4. Dynamically generates input prompts based on tool's input schema
305
+ 5. Executes tool in secure VM sandbox
306
+ 6. Displays results or errors
307
+
308
+ **Features:**
309
+ - Supports nested object inputs
310
+ - Validates required vs optional fields
311
+ - Loads environment variables from `.env` and `lua.skill.yaml`
312
+ - Secure sandbox execution (isolated from host system)
313
+ - Detailed error reporting
314
+
315
+ **Example:**
316
+ ```bash
317
+ $ lua test
318
+ 🧪 Testing Lua skill...
319
+ 📦 Compiling code first...
320
+ ✅ Skill compiled successfully
321
+ 📄 Loaded environment variables from .env file
322
+
323
+ ? 🔧 Select a tool to test:
324
+ ❯ get_weather - Get the weather for a given city
325
+ create_product - Create a new product
326
+ get_user_data - Get user data
327
+
328
+ ✅ Selected tool: get_weather
329
+
330
+ 📝 Enter input values:
331
+ ? city (required): London
332
+
333
+ 🚀 Executing tool...
334
+ Input: {
335
+ "city": "London"
336
+ }
337
+ ✅ Tool execution successful!
338
+ Output: {
339
+ "weather": "3",
340
+ "city": "London",
341
+ "temperature": 15.2,
342
+ "description": "Windspeed 12.3 km/h"
343
+ }
344
+ ```
345
+
346
+ ---
347
+
348
+ ### `lua push`
349
+
350
+ Pushes your compiled skill version to the Lua server.
351
+
352
+ **Usage:**
353
+ ```bash
354
+ lua push
355
+ ```
356
+
357
+ **Interactive Prompts:**
358
+ - Confirmation to push version
359
+
360
+ **What it does:**
361
+ 1. Reads version from `lua.skill.yaml`
362
+ 2. Prompts for confirmation
363
+ 3. Authenticates with API key
364
+ 4. Compiles the skill
365
+ 5. Validates deploy.json matches config
366
+ 6. Uploads version to server
367
+
368
+ **Requirements:**
369
+ - Must be in a skill directory (has `lua.skill.yaml`)
370
+ - Must have run `lua init`
371
+ - Must have valid API key
372
+
373
+ **Example:**
374
+ ```bash
375
+ $ lua push
376
+ ? Are you sure you want to push version 1.0.0? Yes
377
+ ✅ Authenticated
378
+ 🔄 Compiling skill...
379
+ ✅ Skill compiled successfully - 10 tools bundled
380
+ 🔄 Pushing version to server...
381
+ ✅ Version 1.0.0 pushed successfully
382
+ ```
383
+
384
+ **Note:** This uploads to the server but does NOT deploy to production. Use `lua deploy` for production deployment.
385
+
386
+ ---
387
+
388
+ ### `lua deploy`
389
+
390
+ Deploys a specific version to production (all users).
391
+
392
+ **Usage:**
393
+ ```bash
394
+ lua deploy
395
+ ```
396
+
397
+ **Interactive Prompts:**
398
+ 1. Select version to deploy from list
399
+ 2. Confirm deployment with warning
400
+
401
+ **What it does:**
402
+ 1. Fetches all available versions from server
403
+ 2. Displays versions with metadata:
404
+ - Version number
405
+ - Current status (if currently deployed)
406
+ - Created date
407
+ - Creator email
408
+ 3. Prompts for version selection
409
+ 4. Shows warning about production deployment
410
+ 5. Publishes selected version
411
+
412
+ **Features:**
413
+ - Lists all pushed versions
414
+ - Shows which version is currently active
415
+ - Sorts by date (newest first)
416
+ - Requires explicit confirmation
417
+
418
+ **Example:**
419
+ ```bash
420
+ $ lua deploy
421
+ ✅ Authenticated
422
+ 🔄 Fetching available versions...
423
+
424
+ ? Select a version to deploy:
425
+ 1.0.2 - Created: Oct 3, 2025 by you@example.com
426
+ 1.0.1 - Created: Oct 2, 2025 by you@example.com
427
+ ❯ 1.0.0 (CURRENT) - Created: Oct 1, 2025 by you@example.com
428
+
429
+ ? ⚠️ Warning: This version will be deployed to all users. Do you want to proceed? Yes
430
+ 🔄 Publishing version...
431
+ ✅ Version 1.0.0 deployed successfully
432
+ ```
433
+
434
+ **⚠️ WARNING:** This immediately deploys to ALL users. Test thoroughly with `lua dev` first!
435
+
436
+ ---
437
+
438
+ ### `lua dev`
439
+
440
+ Starts development mode with live reloading and chat interface.
441
+
442
+ **Usage:**
443
+ ```bash
444
+ lua dev
445
+ ```
446
+
447
+ **What it does:**
448
+ 1. Compiles the skill
449
+ 2. Pushes all skills to sandbox environment
450
+ 3. Starts local web server on port 3000
451
+ 4. Opens chat interface in your browser
452
+ 5. Watches for file changes
453
+ 6. Auto-recompiles and pushes on changes
454
+
455
+ **Features:**
456
+ - **Live Chat Interface**: Test your skill with conversational AI
457
+ - **Tool Testing**: Test individual tools with custom inputs
458
+ - **WebSocket Logging**: Real-time log streaming
459
+ - **Auto-Reload**: Automatic recompilation on file changes
460
+ - **Environment Management**: Edit `.env` variables in UI
461
+ - **Persona Configuration**: Customize agent behavior
462
+ - **Multi-Skill Support**: Works with multiple skills in one project
463
+
464
+ **Chat Interface Features:**
465
+ ```
466
+ http://localhost:3000
467
+
468
+ Tabs:
469
+ ├── Chat # Chat with your AI agent using sandbox skills
470
+ ├── Tools # Test individual tools with custom inputs
471
+ ├── User Data # View and modify user data
472
+ ├── Environment # Manage environment variables
473
+ ├── Persona # Configure agent personality
474
+ └── Skills # View all skills and their tools
475
+ ```
476
+
477
+ **File Watching:**
478
+ - Watches: `.ts` files in `src/`
479
+ - Ignores: `node_modules/`, `dist/`, `.lua/`, `.git/`
480
+ - Debounce: 500ms (prevents multiple compilations)
481
+
482
+ **Example:**
483
+ ```bash
484
+ $ lua dev
485
+ ✅ Authenticated
486
+ 🔄 Compiling skill...
487
+ ✅ Skill compiled successfully - 10 tools bundled
488
+ 🔄 Pushing skills to sandbox...
489
+ ✅ Pushed 3 skills to sandbox
490
+ 🌐 Chat interface opened in your browser
491
+ 🔍 Watching for file changes... (Press Ctrl+C to stop)
492
+
493
+ # Edit a file...
494
+ 🔄 File changed: src/tools/MyTool.ts - Compiling and pushing...
495
+ ✅ Compilation completed
496
+ ✅ Successfully pushed 3 skills to sandbox
497
+ ```
498
+
499
+ **Stopping Dev Mode:**
500
+ Press `Ctrl+C` to stop the file watcher and server.
501
+
502
+ ---
503
+
504
+ ## Command Reference
505
+
506
+ ### Global Flags
507
+
508
+ All commands support:
509
+ - `--help` - Show command help
510
+ - `--version` - Show CLI version
511
+
512
+ ### Error Handling
513
+
514
+ All commands include:
515
+ - Descriptive error messages
516
+ - Exit codes (0 = success, 1 = error)
517
+ - Helpful troubleshooting hints
518
+
519
+ ### Common Errors
520
+
521
+ **"No API key found"**
522
+ ```bash
523
+ ❌ No API key found. Run `lua auth configure` first.
524
+ ```
525
+ **Solution:** Run `lua auth configure` to set up authentication.
526
+
527
+ **"No lua.skill.yaml found"**
528
+ ```bash
529
+ ❌ No lua.skill.yaml found. Please run this command from a skill directory.
530
+ ```
531
+ **Solution:** Run command from a skill directory or run `lua init` first.
532
+
533
+ **"Missing agentId or skillId"**
534
+ ```bash
535
+ ❌ Missing agentId or skillId in skill configuration
536
+ ```
537
+ **Solution:** Run `lua init` to set up your skill properly.
538
+
539
+ ---
540
+
541
+ ## Workflow Examples
542
+
543
+ ### **Complete Workflow: New Project**
544
+
545
+ ```bash
546
+ # 1. Set up authentication
547
+ lua auth configure
548
+
549
+ # 2. Create new project
550
+ mkdir my-weather-skill
551
+ cd my-weather-skill
552
+ lua init
553
+
554
+ # 3. Customize your tools (edit src/tools/*.ts)
555
+ # 4. Test locally
556
+ lua test
557
+
558
+ # 5. Push to server
559
+ lua push
560
+
561
+ # 6. Start development mode
562
+ lua dev
563
+ # Test in chat interface at http://localhost:3000
564
+
565
+ # 7. When ready, deploy to production
566
+ lua deploy
567
+ ```
568
+
569
+ ---
570
+
571
+ ### **Development Workflow**
572
+
573
+ ```bash
574
+ # Start dev mode
575
+ lua dev
576
+
577
+ # Edit files - auto-reloads
578
+ # Test in chat interface
579
+ # When satisfied, push new version
580
+
581
+ # Stop dev mode (Ctrl+C)
582
+
583
+ # Push production version
584
+ lua push
585
+
586
+ # Deploy to all users
587
+ lua deploy
588
+ ```
589
+
590
+ ---
591
+
592
+ ### **Testing Workflow**
593
+
594
+ ```bash
595
+ # Test individual tools
596
+ lua test
597
+ # Select tool, enter inputs, see results
598
+
599
+ # Test in conversational context
600
+ lua dev
601
+ # Use chat interface to test natural language interaction
602
+ ```
603
+
604
+ ---
605
+
606
+ ## Environment Variables
607
+
608
+ ### Loading Priority
609
+
610
+ Environment variables are loaded in this order (later overrides earlier):
611
+
612
+ 1. System environment (`process.env`)
613
+ 2. `.env` file in project root
614
+ 3. `lua.skill.yaml` under `skill.env`
615
+
616
+ ### Using in Tools
617
+
618
+ ```typescript
619
+ import { env } from 'lua-cli';
620
+
621
+ export class MyTool implements LuaTool {
622
+ async execute(input: any) {
623
+ const apiKey = env('EXTERNAL_API_KEY');
624
+ const baseUrl = env('API_BASE_URL') || 'https://default.com';
625
+
626
+ // Use environment variables...
627
+ }
628
+ }
629
+ ```
630
+
631
+ ### Setting Variables
632
+
633
+ **Option 1: `.env` file**
634
+ ```bash
635
+ # .env
636
+ EXTERNAL_API_KEY=your_key_here
637
+ API_BASE_URL=https://api.example.com
638
+ ```
639
+
640
+ **Option 2: `lua.skill.yaml`**
641
+ ```yaml
642
+ skill:
643
+ name: my-skill
644
+ version: 1.0.0
645
+ env:
646
+ EXTERNAL_API_KEY: your_key_here
647
+ API_BASE_URL: https://api.example.com
648
+ ```
649
+
650
+ **Option 3: Dev Mode UI**
651
+ - Go to http://localhost:3000 during `lua dev`
652
+ - Click "Environment" tab
653
+ - Edit variables in UI
654
+ - Changes saved to `.env` file
655
+
656
+ ---
657
+
658
+ ## Configuration File
659
+
660
+ ### `lua.skill.yaml`
661
+
662
+ Created by `lua init`, updated by compilation.
663
+
664
+ **Structure:**
665
+ ```yaml
666
+ # Agent Configuration
667
+ agent:
668
+ agentId: agent_abc123 # Your agent ID
669
+ orgId: org_xyz789 # Organization ID
670
+ persona: "..." # Agent personality (optional)
671
+ welcomeMessage: "..." # Welcome message (optional)
672
+
673
+ # Legacy single skill format (deprecated)
674
+ skill:
675
+ name: my-skill
676
+ version: 1.0.0
677
+ skillId: skill_legacy123
678
+
679
+ # New multi-skill format (recommended)
680
+ skills:
681
+ - name: general-skill
682
+ version: 1.0.0
683
+ skillId: skill_abc123
684
+ - name: product-skill
685
+ version: 1.0.0
686
+ skillId: skill_def456
687
+
688
+ # Environment Variables (optional)
689
+ skill:
690
+ env:
691
+ API_KEY: your_key_here
692
+ BASE_URL: https://api.example.com
693
+ ```
694
+
695
+ **Auto-managed Fields:**
696
+ - `skillId` - Automatically created during compilation
697
+ - `skills` array - Auto-populated from your code
698
+
699
+ **Manual Fields:**
700
+ - `agentId` - Set during `lua init`
701
+ - `orgId` - Set during `lua init`
702
+ - `version` - Update manually when releasing new versions
703
+ - `env` - Set your environment variables here
704
+
705
+ ---
706
+
707
+ ## Troubleshooting
708
+
709
+ ### Common Issues
710
+
711
+ **Skill not found during dev**
712
+ ```bash
713
+ 💡 The skill doesn't exist on the server.
714
+ Please run "lua push" first to deploy your skill, then try "lua dev" again.
715
+ ```
716
+ **Solution:** Run `lua push` before `lua dev`.
717
+
718
+ **Compilation fails**
719
+ ```bash
720
+ ❌ No index.ts found in current directory or src/ directory
721
+ ```
722
+ **Solution:** Create `index.ts` or `src/index.ts` with your skill definition.
723
+
724
+ **Version mismatch**
725
+ ```bash
726
+ ❌ Version mismatch: config has 1.0.1, deploy.json has 1.0.0
727
+ ```
728
+ **Solution:** Recompile after changing version in `lua.skill.yaml`.
729
+
730
+ ### Getting Help
731
+
732
+ - Check command help: `lua [command] --help`
733
+ - Visit documentation: https://docs.lua.ai
734
+ - View examples in template: Check `template/` directory after install
735
+
736
+ ---
737
+
738
+ ## Best Practices
739
+
740
+ ### Versioning
741
+ - Use semantic versioning: `MAJOR.MINOR.PATCH`
742
+ - Increment PATCH for bug fixes
743
+ - Increment MINOR for new features
744
+ - Increment MAJOR for breaking changes
745
+
746
+ ### Development
747
+ - Always test with `lua test` before pushing
748
+ - Use `lua dev` for iterative development
749
+ - Test thoroughly before deploying to production
750
+ - Keep `.env` file in `.gitignore`
751
+
752
+ ### Deployment
753
+ - Push new versions frequently for testing
754
+ - Only deploy stable versions to production
755
+ - Document changes between versions
756
+ - Test in sandbox (dev mode) before deploying
757
+
758
+ ---
759
+
760
+ ## Advanced Usage
761
+
762
+ ### Multiple Skills in One Project
763
+
764
+ You can define multiple skills in `index.ts`:
765
+
766
+ ```typescript
767
+ const skill1 = new LuaSkill({
768
+ name: 'general-skill',
769
+ description: '...',
770
+ context: '...',
771
+ tools: [tool1, tool2]
772
+ });
773
+
774
+ const skill2 = new LuaSkill({
775
+ name: 'ecommerce-skill',
776
+ description: '...',
777
+ context: '...',
778
+ tools: [tool3, tool4]
779
+ });
780
+ ```
781
+
782
+ The CLI automatically:
783
+ - Detects all skills
784
+ - Creates separate skill IDs
785
+ - Bundles all tools
786
+ - Manages multi-skill deployments
787
+
788
+ ### Custom Build Configuration
789
+
790
+ Modify `tsconfig.json` for TypeScript settings.
791
+
792
+ The CLI uses:
793
+ - **esbuild** for fast bundling
794
+ - **ts-morph** for AST analysis
795
+ - **VM sandboxing** for secure execution
796
+
797
+ ---
798
+
799
+ ## Command Summary
800
+
801
+ | Command | Purpose | Requires |
802
+ |---------|---------|----------|
803
+ | `lua auth configure` | Set up API key | Nothing |
804
+ | `lua auth key` | Show API key | API key |
805
+ | `lua auth logout` | Delete API key | API key |
806
+ | `lua init` | Initialize project | API key |
807
+ | `lua compile` | Compile skill | Skill directory |
808
+ | `lua test` | Test tools | Compiled skill |
809
+ | `lua push` | Upload version | Compiled skill, API key |
810
+ | `lua deploy` | Deploy to prod | Pushed versions |
811
+ | `lua dev` | Dev mode | Compiled skill, pushed version |
812
+
813
+ ---
814
+
815
+ **For detailed API documentation, see `API_REFERENCE.md`**
816
+ **For template documentation, see `TEMPLATE_GUIDE.md`**
817
+ **For development guide, see `DEVELOPER_GUIDE.md`**
818
+