lua-cli 1.3.0-alpha.1 → 1.3.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/CHANGELOG.md +8 -3
- package/README.md +168 -14
- package/dist/commands/agents.js +5 -9
- package/dist/commands/compile.js +252 -70
- package/dist/commands/deploy-new.d.ts +0 -20
- package/dist/commands/deploy-new.js +130 -128
- package/dist/commands/deploy.js +15 -43
- package/dist/commands/dev.d.ts +63 -0
- package/dist/commands/dev.js +656 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/init.js +230 -42
- package/dist/commands/push.js +25 -36
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1
- package/dist/services/api.d.ts +195 -0
- package/dist/services/api.js +209 -0
- package/dist/services/auth.d.ts +82 -0
- package/dist/services/auth.js +101 -51
- package/dist/user-data-api.d.ts +52 -0
- package/dist/user-data-api.js +151 -0
- package/dist/utils/files.d.ts +4 -1
- package/dist/utils/files.js +62 -16
- package/dist/web/app.css +1050 -0
- package/dist/web/app.js +79 -0
- package/dist/web/tools-page.css +377 -0
- package/package.json +17 -4
- package/template/package-lock.json +32 -3
- package/template/package.json +3 -1
- package/template/{index.ts → src/index.ts} +9 -3
- package/template/src/tools/UserPreferencesTool.ts +73 -0
- package/template/tools/UserPreferencesTool.ts +73 -0
- package/template/tsconfig.json +1 -1
- package/template/.lua/deploy.json +0 -148
- /package/template/{services → src/services}/ApiService.ts +0 -0
- /package/template/{services → src/services}/GetWeather.ts +0 -0
- /package/template/{services → src/services}/MathService.ts +0 -0
- /package/template/{tools → src/tools}/AdvancedMathTool.ts +0 -0
- /package/template/{tools → src/tools}/CalculatorTool.ts +0 -0
- /package/template/{tools → src/tools}/CreatePostTool.ts +0 -0
- /package/template/{tools → src/tools}/GetUserDataTool.ts +0 -0
- /package/template/{tools → src/tools}/GetWeatherTool.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,12 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
- **Centralized CLI Utilities**: New `src/utils/cli.ts` module for consistent error handling and output management
|
|
12
12
|
- **Command Restructuring**: Reorganized commands into logical groups:
|
|
13
13
|
- `lua auth` - Authentication management (configure, logout, key)
|
|
14
|
-
- `lua skill` - Skill development (init, compile, test, push, deploy)
|
|
14
|
+
- `lua skill` - Skill development (init, compile, test, push, dev, deploy)
|
|
15
15
|
- **Enhanced Error Handling**: Graceful handling of Ctrl+C (SIGINT) across all commands
|
|
16
16
|
- **Consistent Output Management**: Standardized progress messages, success messages, and prompt clearing
|
|
17
17
|
- **Tool Name Validation**: Regex-based validation for tool names (alphanumeric, hyphens, underscores only)
|
|
18
18
|
- **Version Management**: TOML-based version tracking with automatic versioning
|
|
19
|
-
- **Skill Push/Deploy**: New commands for version management and production deployment
|
|
19
|
+
- **Skill Push/Deploy/Dev**: New commands for version management, sandbox development, and production deployment
|
|
20
|
+
- **Smart Sandbox Management**: Dev command intelligently reuses existing sandbox skill IDs and falls back to creating new ones when needed
|
|
21
|
+
- **File Watching Mode**: Dev command now watches for file changes and automatically recompiles and pushes to sandbox
|
|
22
|
+
- **Web Chat Interface**: Dev command now includes a beautiful web-based chat interface for real-time skill testing
|
|
23
|
+
- **Live Log Panel**: Real-time log feed with WebSocket connection for monitoring execution details
|
|
24
|
+
- **Log Details Support**: Enhanced log display with detailed information sections and proper error handling
|
|
20
25
|
- **Comprehensive Testing**: 100% test coverage for CLI utilities with 44 passing tests
|
|
21
26
|
|
|
22
27
|
### Changed
|
|
@@ -27,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
27
32
|
- `lua init` → `lua skill init`
|
|
28
33
|
- `lua compile` → `lua skill compile`
|
|
29
34
|
- `lua test` → `lua skill test`
|
|
30
|
-
- Added `lua skill push` and `lua skill deploy`
|
|
35
|
+
- Added `lua skill push`, `lua skill dev`, and `lua skill deploy`
|
|
31
36
|
- **LuaSkill Constructor**: Now accepts object `{description, context}` instead of separate parameters
|
|
32
37
|
- **TOML Configuration**: Added `version` and `skillId` fields to `lua.skill.toml`
|
|
33
38
|
- **Error Messages**: Standardized format: `"❌ Error during [command]: [message]"`
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ lua --help
|
|
|
27
27
|
- 🧪 **Interactive Testing**: Test your tools with real-time execution
|
|
28
28
|
- 🚀 **Deployment**: Compile and deploy skills to the Lua platform
|
|
29
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
|
|
30
31
|
- 📚 **Comprehensive Documentation**: Complete guides and examples
|
|
31
32
|
|
|
32
33
|
## Quick Start
|
|
@@ -41,7 +42,7 @@ lua --help
|
|
|
41
42
|
```bash
|
|
42
43
|
lua skill init
|
|
43
44
|
```
|
|
44
|
-
|
|
45
|
+
Choose between selecting an existing agent or creating a new one, then provide skill details.
|
|
45
46
|
|
|
46
47
|
3. **Develop your tools:**
|
|
47
48
|
```bash
|
|
@@ -111,9 +112,16 @@ lua skill init
|
|
|
111
112
|
This command will:
|
|
112
113
|
- Fetch your organizations and agents from the API
|
|
113
114
|
- Let you select an organization by name
|
|
114
|
-
-
|
|
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
|
|
115
123
|
- Prompt for skill name and description
|
|
116
|
-
- Create a `lua.skill.
|
|
124
|
+
- Create a `lua.skill.yaml` configuration file with agent details
|
|
117
125
|
- Copy template files to the current directory
|
|
118
126
|
|
|
119
127
|
#### `lua skill compile`
|
|
@@ -162,7 +170,43 @@ This command will:
|
|
|
162
170
|
- Compile your skill first
|
|
163
171
|
- Confirm the version you want to push
|
|
164
172
|
- Send the compiled skill data to the server
|
|
165
|
-
- Store the skill ID in your
|
|
173
|
+
- Store the skill ID in your YAML file
|
|
174
|
+
|
|
175
|
+
#### `lua skill dev`
|
|
176
|
+
|
|
177
|
+
Push your compiled skill version to the sandbox for development and testing with automatic file watching and web chat interface.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
lua skill dev
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
This command will:
|
|
184
|
+
- Compile your skill first
|
|
185
|
+
- Confirm the version you want to push to sandbox
|
|
186
|
+
- **Smart Sandbox Management**:
|
|
187
|
+
- If you have a previous sandbox skill ID stored, it will try to update the existing sandbox
|
|
188
|
+
- If the update fails or no sandbox exists, it will create a new one
|
|
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.lua.dev/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
|
|
166
210
|
|
|
167
211
|
#### `lua skill deploy`
|
|
168
212
|
|
|
@@ -237,17 +281,19 @@ template/
|
|
|
237
281
|
|
|
238
282
|
## Configuration File
|
|
239
283
|
|
|
240
|
-
The `lua.skill.
|
|
284
|
+
The `lua.skill.yaml` file is created when you run `lua skill init`:
|
|
241
285
|
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
agentId
|
|
245
|
-
orgId
|
|
286
|
+
```yaml
|
|
287
|
+
agent:
|
|
288
|
+
agentId: "your-agent-id"
|
|
289
|
+
orgId: "your-organization-id"
|
|
290
|
+
persona: "Generated persona description" # Only for newly created agents
|
|
291
|
+
welcomeMessage: "Welcome message" # Only for newly created agents
|
|
246
292
|
|
|
247
|
-
|
|
248
|
-
name
|
|
249
|
-
version
|
|
250
|
-
skillId
|
|
293
|
+
skill:
|
|
294
|
+
name: "Your Skill Name"
|
|
295
|
+
version: "0.0.1"
|
|
296
|
+
skillId: "your-skill-id"
|
|
251
297
|
```
|
|
252
298
|
|
|
253
299
|
## Authentication Methods
|
|
@@ -348,6 +394,106 @@ To contribute to this project:
|
|
|
348
394
|
|
|
349
395
|
MIT License - see [LICENSE](LICENSE) file for details.
|
|
350
396
|
|
|
397
|
+
## User Data API
|
|
398
|
+
|
|
399
|
+
The Lua CLI provides a built-in User Data API that allows your tools to interact with persistent user data stored in the Lua system.
|
|
400
|
+
|
|
401
|
+
### Basic Usage
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
import { user } from 'lua-cli/user-data-api';
|
|
405
|
+
|
|
406
|
+
// Get user data
|
|
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
|
+
});
|
|
418
|
+
|
|
419
|
+
// Update existing data
|
|
420
|
+
await user.data.update({
|
|
421
|
+
name: 'Jane Doe',
|
|
422
|
+
preferences: {
|
|
423
|
+
theme: 'light',
|
|
424
|
+
language: 'es'
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// Clear all user data
|
|
429
|
+
await user.data.clear();
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Using in Tools
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
import { LuaTool } from 'lua-cli/skill';
|
|
436
|
+
import { user } from 'lua-cli/user-data-api';
|
|
437
|
+
import { z } from 'zod';
|
|
438
|
+
|
|
439
|
+
export class UserPreferencesTool extends LuaTool {
|
|
440
|
+
constructor() {
|
|
441
|
+
super('user-preferences', 'Manage user preferences');
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async execute(input: { action: string; key?: string; value?: string }) {
|
|
445
|
+
const { action, key, value } = input;
|
|
446
|
+
|
|
447
|
+
switch (action) {
|
|
448
|
+
case 'get':
|
|
449
|
+
const userData = await user.data.get();
|
|
450
|
+
return { preferences: userData.preferences || {} };
|
|
451
|
+
|
|
452
|
+
case 'set':
|
|
453
|
+
if (!key || !value) {
|
|
454
|
+
throw new Error('Key and value are required for set action');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const currentData = await user.data.get();
|
|
458
|
+
const updatedData = {
|
|
459
|
+
...currentData,
|
|
460
|
+
preferences: {
|
|
461
|
+
...currentData.preferences,
|
|
462
|
+
[key]: value
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
await user.data.update(updatedData);
|
|
467
|
+
return { success: true, message: `Set ${key} to ${value}` };
|
|
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
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
getInputSchema() {
|
|
479
|
+
return z.object({
|
|
480
|
+
action: z.enum(['get', 'set', 'clear']).describe('Action to perform'),
|
|
481
|
+
key: z.string().optional().describe('Preference key (required for set action)'),
|
|
482
|
+
value: z.string().optional().describe('Preference value (required for set action)')
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### API Reference
|
|
489
|
+
|
|
490
|
+
- `user.data.get()` - Retrieves current user data
|
|
491
|
+
- `user.data.create(data)` - Creates or updates user data
|
|
492
|
+
- `user.data.update(data)` - Updates existing user data (alias for create)
|
|
493
|
+
- `user.data.clear()` - Clears all user data
|
|
494
|
+
|
|
495
|
+
For more details, see [USER_DATA_API.md](./USER_DATA_API.md).
|
|
496
|
+
|
|
351
497
|
## Support
|
|
352
498
|
|
|
353
499
|
For support and questions:
|
|
@@ -356,11 +502,19 @@ For support and questions:
|
|
|
356
502
|
|
|
357
503
|
## Changelog
|
|
358
504
|
|
|
505
|
+
### 1.4.0
|
|
506
|
+
- **Agent Creation**: Added ability to create new agents during `lua skill init`
|
|
507
|
+
- **Agent Type Selection**: Choose from various agent types (Base Agent, Shopify, WooCommerce, etc.)
|
|
508
|
+
- **Metadata Collection**: Automatic collection of required metadata for agent types
|
|
509
|
+
- **Feature Configuration**: Enable/disable features like RAG, tickets, web search
|
|
510
|
+
- **Persona Generation**: Automatic persona and welcome message generation for new agents
|
|
511
|
+
- **Enhanced YAML**: Added persona and welcome message fields to configuration file
|
|
512
|
+
|
|
359
513
|
### 1.3.0
|
|
360
514
|
- **Command Restructure**: Reorganized commands under `lua auth` and `lua skill` groups
|
|
361
515
|
- **New Push Command**: Added `lua skill push` to push versions to server
|
|
362
516
|
- **New Deploy Command**: Added `lua skill deploy` to deploy versions to production
|
|
363
|
-
- **Version Management**: Added version field to
|
|
517
|
+
- **Version Management**: Added version field to YAML configuration
|
|
364
518
|
- **Improved UX**: Better command organization and intuitive naming
|
|
365
519
|
- **Enhanced Workflow**: Complete skill lifecycle from init to production deployment
|
|
366
520
|
|
package/dist/commands/agents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ApiService } from '../services/api.js';
|
|
2
2
|
import { loadApiKey } from "../services/auth.js";
|
|
3
3
|
import { withErrorHandling, writeSuccess } from "../utils/cli.js";
|
|
4
4
|
export async function agentsCommand() {
|
|
@@ -8,16 +8,12 @@ export async function agentsCommand() {
|
|
|
8
8
|
console.error("❌ No API key found. Run `lua configure` first.");
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
|
-
const response = await
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
console.error(`❌ Error ${response.status}: ${await response.text()}`);
|
|
11
|
+
const response = await ApiService.Agent.getOrganizations(apiKey);
|
|
12
|
+
if (!response.success) {
|
|
13
|
+
console.error(`❌ Error: ${response.error?.message || 'Unknown error'}`);
|
|
18
14
|
process.exit(1);
|
|
19
15
|
}
|
|
20
|
-
const data =
|
|
16
|
+
const data = response.data;
|
|
21
17
|
writeSuccess("✅ Agents retrieved successfully:");
|
|
22
18
|
console.log(JSON.stringify(data, null, 2));
|
|
23
19
|
}, "agents listing");
|