lua-cli 1.2.1 → 1.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.0-alpha.1] - 2024-12-19
9
+
10
+ ### Added
11
+ - **Centralized CLI Utilities**: New `src/utils/cli.ts` module for consistent error handling and output management
12
+ - **Command Restructuring**: Reorganized commands into logical groups:
13
+ - `lua auth` - Authentication management (configure, logout, key)
14
+ - `lua skill` - Skill development (init, compile, test, push, deploy)
15
+ - **Enhanced Error Handling**: Graceful handling of Ctrl+C (SIGINT) across all commands
16
+ - **Consistent Output Management**: Standardized progress messages, success messages, and prompt clearing
17
+ - **Tool Name Validation**: Regex-based validation for tool names (alphanumeric, hyphens, underscores only)
18
+ - **Version Management**: TOML-based version tracking with automatic versioning
19
+ - **Skill Push/Deploy**: New commands for version management and production deployment
20
+ - **Comprehensive Testing**: 100% test coverage for CLI utilities with 44 passing tests
21
+
22
+ ### Changed
23
+ - **Command Structure**:
24
+ - `lua configure` → `lua auth configure`
25
+ - `lua destroy` → `lua auth logout`
26
+ - `lua apiKey` → `lua auth key`
27
+ - `lua init` → `lua skill init`
28
+ - `lua compile` → `lua skill compile`
29
+ - `lua test` → `lua skill test`
30
+ - Added `lua skill push` and `lua skill deploy`
31
+ - **LuaSkill Constructor**: Now accepts object `{description, context}` instead of separate parameters
32
+ - **TOML Configuration**: Added `version` and `skillId` fields to `lua.skill.toml`
33
+ - **Error Messages**: Standardized format: `"❌ Error during [command]: [message]"`
34
+ - **Output Consistency**: All commands now use centralized utilities for consistent UX
35
+
36
+ ### Technical Improvements
37
+ - **Zero Code Duplication**: Centralized error handling eliminates repetitive code
38
+ - **Professional UX**: Clean, consistent output with preserved command history
39
+ - **Maintainable Architecture**: Single source of truth for CLI patterns
40
+ - **Type Safety**: Enhanced TypeScript interfaces and validation
41
+ - **Test Coverage**: Comprehensive test suite with 100% CLI utility coverage
42
+
43
+ ### Security
44
+ - **Input Validation**: Tool name validation prevents injection attacks
45
+ - **Graceful Cancellation**: Proper handling of user interruptions
46
+ - **Error Isolation**: Centralized error handling prevents crashes
47
+
48
+ ### Documentation
49
+ - **Updated README**: Reflects new command structure and features
50
+ - **Developer Guide**: Enhanced documentation for LuaSkill constructor
51
+ - **API Reference**: Updated examples and usage patterns
52
+
8
53
  ## [1.2.1] - 2024-09-19
9
54
 
10
55
  ### Fixed
package/README.md CHANGED
@@ -33,13 +33,13 @@ lua --help
33
33
 
34
34
  1. **Configure your authentication:**
35
35
  ```bash
36
- lua configure
36
+ lua auth configure
37
37
  ```
38
38
  Choose between API key or email authentication methods.
39
39
 
40
40
  2. **Initialize a new skill project:**
41
41
  ```bash
42
- lua init
42
+ lua skill init
43
43
  ```
44
44
  Select your organization and agent, then provide skill details.
45
45
 
@@ -51,25 +51,27 @@ lua --help
51
51
 
52
52
  4. **Compile your skill:**
53
53
  ```bash
54
- lua compile
54
+ lua skill compile
55
55
  ```
56
56
  Bundles dependencies and creates deployable files.
57
57
 
58
58
  5. **Test your tools:**
59
59
  ```bash
60
- lua test
60
+ lua skill test
61
61
  ```
62
62
  Interactive testing interface for your tools.
63
63
 
64
64
  6. **Deploy your skill:**
65
65
  ```bash
66
- lua deploy
66
+ lua skill deploy
67
67
  ```
68
68
  Deploy to the Lua platform.
69
69
 
70
70
  ## Commands
71
71
 
72
- ### `lua configure`
72
+ ### Authentication Commands
73
+
74
+ #### `lua auth configure`
73
75
 
74
76
  Set up your authentication credentials. You can choose between:
75
77
 
@@ -77,55 +79,49 @@ Set up your authentication credentials. You can choose between:
77
79
  - **Email**: Email-based OTP authentication
78
80
 
79
81
  ```bash
80
- lua configure
81
- ```
82
-
83
- ### `lua init`
84
-
85
- Initialize a new Lua skill project in the current directory.
86
-
87
- ```bash
88
- lua init
82
+ lua auth configure
89
83
  ```
90
84
 
91
- This command will:
92
- - Fetch your organizations and agents from the API
93
- - Let you select an organization by name
94
- - Let you choose an agent from the selected organization
95
- - Prompt for skill name and description
96
- - Create a `lua.skill.toml` configuration file
97
- - Copy template files to the current directory
98
-
99
- ### `lua apiKey`
85
+ #### `lua auth key`
100
86
 
101
87
  Display your stored API key (with confirmation prompt).
102
88
 
103
89
  ```bash
104
- lua apiKey
90
+ lua auth key
105
91
  ```
106
92
 
107
- ### `lua agents`
93
+ #### `lua auth logout`
108
94
 
109
- Fetch and display your agents from the HeyLua API.
95
+ Delete your stored API key and credentials.
110
96
 
111
97
  ```bash
112
- lua agents
98
+ lua auth logout
113
99
  ```
114
100
 
115
- ### `lua destroy`
101
+ ### Skill Management Commands
116
102
 
117
- Delete your stored API key and credentials.
103
+ #### `lua skill init`
104
+
105
+ Initialize a new Lua skill project in the current directory.
118
106
 
119
107
  ```bash
120
- lua destroy
108
+ lua skill init
121
109
  ```
122
110
 
123
- ### `lua compile`
111
+ This command will:
112
+ - Fetch your organizations and agents from the API
113
+ - Let you select an organization by name
114
+ - Let you choose an agent from the selected organization
115
+ - Prompt for skill name and description
116
+ - Create a `lua.skill.toml` configuration file
117
+ - Copy template files to the current directory
118
+
119
+ #### `lua skill compile`
124
120
 
125
121
  Compile your LuaSkill and bundle all dependencies.
126
122
 
127
123
  ```bash
128
- lua compile
124
+ lua skill compile
129
125
  ```
130
126
 
131
127
  This command will:
@@ -139,12 +135,12 @@ This command will:
139
135
  - `--watch` - Watch for changes and recompile automatically
140
136
  - `--minify` - Minify the bundled code
141
137
 
142
- ### `lua test`
138
+ #### `lua skill test`
143
139
 
144
140
  Interactive testing interface for your tools.
145
141
 
146
142
  ```bash
147
- lua test
143
+ lua skill test
148
144
  ```
149
145
 
150
146
  Features:
@@ -154,23 +150,39 @@ Features:
154
150
  - Error reporting and debugging
155
151
  - Mock data support
156
152
 
157
- ### `lua deploy`
153
+ #### `lua skill push`
154
+
155
+ Push your compiled skill version to the server.
156
+
157
+ ```bash
158
+ lua skill push
159
+ ```
160
+
161
+ This command will:
162
+ - Compile your skill first
163
+ - Confirm the version you want to push
164
+ - Send the compiled skill data to the server
165
+ - Store the skill ID in your TOML file
158
166
 
159
- Deploy your compiled skill to the Lua platform.
167
+ #### `lua skill deploy`
168
+
169
+ Deploy a version to production.
160
170
 
161
171
  ```bash
162
- lua deploy
172
+ lua skill deploy
163
173
  ```
164
174
 
175
+ This command will:
176
+ - Fetch available versions from the server
177
+ - Let you select which version to deploy
178
+ - Show a warning about deploying to all users
179
+ - Publish the selected version to production
180
+
165
181
  **Requirements:**
166
- - Valid API key (configured with `lua configure`)
167
- - Compiled skill (run `lua compile` first)
182
+ - Valid API key (configured with `lua auth configure`)
183
+ - Compiled skill (run `lua skill compile` first)
168
184
  - Active internet connection
169
185
 
170
- **Output:**
171
- - Skill deployed to your selected agent
172
- - Deployment confirmation and status
173
-
174
186
  ## Template System
175
187
 
176
188
  The Lua CLI includes a comprehensive template system with examples and documentation:
@@ -225,7 +237,7 @@ template/
225
237
 
226
238
  ## Configuration File
227
239
 
228
- The `lua.skill.toml` file is created when you run `lua init`:
240
+ The `lua.skill.toml` file is created when you run `lua skill init`:
229
241
 
230
242
  ```toml
231
243
  [agent]
@@ -234,21 +246,22 @@ orgId = "your-organization-id"
234
246
 
235
247
  [skill]
236
248
  name = "Your Skill Name"
237
- description = "Description of your skill"
249
+ version = "0.0.1"
250
+ skillId = "your-skill-id"
238
251
  ```
239
252
 
240
253
  ## Authentication Methods
241
254
 
242
255
  ### API Key Authentication
243
256
 
244
- 1. Run `lua configure`
257
+ 1. Run `lua auth configure`
245
258
  2. Select "API Key"
246
259
  3. Enter your API key when prompted
247
260
  4. The key is validated and stored securely
248
261
 
249
262
  ### Email Authentication
250
263
 
251
- 1. Run `lua configure`
264
+ 1. Run `lua auth configure`
252
265
  2. Select "Email"
253
266
  3. Enter your email address
254
267
  4. Check your email for the OTP code
@@ -267,7 +280,7 @@ description = "Description of your skill"
267
280
  ### 1. Project Setup
268
281
  ```bash
269
282
  # Initialize a new skill project
270
- lua init
283
+ lua skill init
271
284
 
272
285
  # Or copy the template
273
286
  cp -r template/ my-skill/
@@ -285,26 +298,32 @@ npm install
285
298
  ### 3. Testing
286
299
  ```bash
287
300
  # Compile your skill
288
- lua compile
301
+ lua skill compile
289
302
 
290
303
  # Test your tools interactively
291
- lua test
304
+ lua skill test
292
305
  ```
293
306
 
294
307
  ### 4. Deployment
295
308
  ```bash
296
- # Deploy to Lua platform
297
- lua deploy
309
+ # Push version to server
310
+ lua skill push
311
+
312
+ # Deploy to production
313
+ lua skill deploy
298
314
  ```
299
315
 
300
316
  ### 5. Iteration
301
317
  ```bash
302
318
  # Make changes to your tools
303
319
  # Recompile and test
304
- lua compile && lua test
320
+ lua skill compile && lua skill test
321
+
322
+ # Push updates
323
+ lua skill push
305
324
 
306
325
  # Deploy updates
307
- lua deploy
326
+ lua skill deploy
308
327
  ```
309
328
 
310
329
  ## Requirements
@@ -333,10 +352,18 @@ MIT License - see [LICENSE](LICENSE) file for details.
333
352
 
334
353
  For support and questions:
335
354
  - Create an issue on [GitHub](https://github.com/lua-ai-global/lua-cli/issues)
336
- - Contact: stefan@heylua.ai
355
+ - Contact: stefan@lua.dev
337
356
 
338
357
  ## Changelog
339
358
 
359
+ ### 1.3.0
360
+ - **Command Restructure**: Reorganized commands under `lua auth` and `lua skill` groups
361
+ - **New Push Command**: Added `lua skill push` to push versions to server
362
+ - **New Deploy Command**: Added `lua skill deploy` to deploy versions to production
363
+ - **Version Management**: Added version field to TOML configuration
364
+ - **Improved UX**: Better command organization and intuitive naming
365
+ - **Enhanced Workflow**: Complete skill lifecycle from init to production deployment
366
+
340
367
  ### 1.2.0
341
368
  - **Tool Development Framework**: Complete LuaSkill and LuaTool framework
342
369
  - **Dependency Bundling**: Automatic bundling of npm packages using esbuild
@@ -1,20 +1,24 @@
1
1
  import fetch from "node-fetch";
2
2
  import { loadApiKey } from "../services/auth.js";
3
+ import { withErrorHandling, writeSuccess } from "../utils/cli.js";
3
4
  export async function agentsCommand() {
4
- const apiKey = await loadApiKey();
5
- if (!apiKey) {
6
- console.error("❌ No API key found. Run `lua configure` first.");
7
- process.exit(1);
8
- }
9
- const response = await fetch("https://api.heylua.ai/admin", {
10
- headers: {
11
- Authorization: `Bearer ${apiKey}`,
12
- },
13
- });
14
- if (!response.ok) {
15
- console.error(`❌ Error ${response.status}: ${await response.text()}`);
16
- process.exit(1);
17
- }
18
- const data = await response.json();
19
- console.log("✅ Agents:", JSON.stringify(data, null, 2));
5
+ return withErrorHandling(async () => {
6
+ const apiKey = await loadApiKey();
7
+ if (!apiKey) {
8
+ console.error("❌ No API key found. Run `lua configure` first.");
9
+ process.exit(1);
10
+ }
11
+ const response = await fetch("https://api.lua.dev/admin", {
12
+ headers: {
13
+ Authorization: `Bearer ${apiKey}`,
14
+ },
15
+ });
16
+ if (!response.ok) {
17
+ console.error(`❌ Error ${response.status}: ${await response.text()}`);
18
+ process.exit(1);
19
+ }
20
+ const data = await response.json();
21
+ writeSuccess("✅ Agents retrieved successfully:");
22
+ console.log(JSON.stringify(data, null, 2));
23
+ }, "agents listing");
20
24
  }
@@ -1,24 +1,29 @@
1
1
  import inquirer from "inquirer";
2
2
  import { loadApiKey } from "../services/auth.js";
3
+ import { withErrorHandling, clearPromptLines, writeProgress, writeSuccess } from "../utils/cli.js";
3
4
  export async function apiKeyCommand() {
4
- const apiKey = await loadApiKey();
5
- if (!apiKey) {
6
- console.log("ℹ️ No API key found. Run `lua configure` first.");
7
- return;
8
- }
9
- const { confirm } = await inquirer.prompt([
10
- {
11
- type: "confirm",
12
- name: "confirm",
13
- message: "This will display your API key. Are you sure you want to continue?",
14
- default: false
5
+ return withErrorHandling(async () => {
6
+ const apiKey = await loadApiKey();
7
+ if (!apiKey) {
8
+ writeProgress("ℹ️ No API key found. Run `lua configure` first.");
9
+ return;
15
10
  }
16
- ]);
17
- if (confirm) {
18
- console.log("🔑 Your API key:");
19
- console.log(apiKey);
20
- }
21
- else {
22
- console.log("ℹ️ API key display cancelled.");
23
- }
11
+ const { confirm } = await inquirer.prompt([
12
+ {
13
+ type: "confirm",
14
+ name: "confirm",
15
+ message: "This will display your API key. Are you sure you want to continue?",
16
+ default: false
17
+ }
18
+ ]);
19
+ // Clear the confirmation prompt lines
20
+ clearPromptLines(2);
21
+ if (confirm) {
22
+ writeSuccess("🔑 Your API key:");
23
+ console.log(apiKey);
24
+ }
25
+ else {
26
+ writeProgress("ℹ️ API key display cancelled.");
27
+ }
28
+ }, "key display");
24
29
  }
@@ -0,0 +1 @@
1
+ export declare function compileCommand(): Promise<void>;