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 +45 -0
- package/README.md +83 -56
- package/dist/commands/agents.js +20 -16
- package/dist/commands/apiKey.js +24 -19
- package/dist/commands/compile.d.ts +1 -0
- package/dist/commands/compile.js +822 -0
- package/dist/commands/configure.js +93 -68
- package/dist/commands/deploy-new.d.ts +20 -0
- package/dist/commands/deploy-new.js +128 -0
- package/dist/commands/deploy.d.ts +19 -0
- package/dist/commands/deploy.js +102 -756
- package/dist/commands/destroy.js +26 -21
- package/dist/commands/index.d.ts +3 -2
- package/dist/commands/index.js +3 -2
- package/dist/commands/init.js +108 -61
- package/dist/commands/push.d.ts +22 -0
- package/dist/commands/push.js +138 -0
- package/dist/commands/test.js +14 -15
- package/dist/index.js +29 -19
- package/dist/services/auth.d.ts +20 -0
- package/dist/services/auth.js +43 -4
- package/dist/skill.d.ts +22 -1
- package/dist/skill.js +21 -1
- package/dist/types/index.d.ts +16 -2
- package/dist/types/index.js +16 -1
- package/dist/utils/cli.d.ts +34 -0
- package/dist/utils/cli.js +58 -0
- package/dist/utils/files.d.ts +1 -1
- package/dist/utils/files.js +4 -3
- package/package.json +3 -3
- package/template/.lua/deploy.json +5 -2
- package/template/index.ts +4 -1
package/dist/skill.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { ZodType } from "zod";
|
|
2
2
|
import { LuaTool } from "./types/index.js";
|
|
3
3
|
export { LuaTool };
|
|
4
|
+
export interface LuaSkillConfig {
|
|
5
|
+
description: string;
|
|
6
|
+
context: string;
|
|
7
|
+
}
|
|
4
8
|
export declare class LuaSkill {
|
|
5
9
|
private readonly tools;
|
|
6
|
-
|
|
10
|
+
private readonly description;
|
|
11
|
+
private readonly context;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new LuaSkill instance
|
|
14
|
+
*
|
|
15
|
+
* @param config - Configuration object containing skill metadata
|
|
16
|
+
* @param config.description - Short description of what the skill does (1-2 sentences)
|
|
17
|
+
* @param config.context - Detailed explanation of how the agent should use the tools
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const skill = new LuaSkill({
|
|
22
|
+
* description: "Weather and calculator utilities",
|
|
23
|
+
* context: "This skill provides weather information for any city and basic mathematical operations. Use get_weather for current conditions and calculator for arithmetic operations."
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
constructor(config: LuaSkillConfig);
|
|
7
28
|
addTool<TInput extends ZodType, TOutput extends ZodType>(tool: LuaTool<TInput, TOutput>): void;
|
|
8
29
|
run(input: Record<string, any>): Promise<any>;
|
|
9
30
|
}
|
package/dist/skill.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
import { assertValidToolName } from "./types/index.js";
|
|
1
2
|
export class LuaSkill {
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new LuaSkill instance
|
|
5
|
+
*
|
|
6
|
+
* @param config - Configuration object containing skill metadata
|
|
7
|
+
* @param config.description - Short description of what the skill does (1-2 sentences)
|
|
8
|
+
* @param config.context - Detailed explanation of how the agent should use the tools
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const skill = new LuaSkill({
|
|
13
|
+
* description: "Weather and calculator utilities",
|
|
14
|
+
* context: "This skill provides weather information for any city and basic mathematical operations. Use get_weather for current conditions and calculator for arithmetic operations."
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
constructor(config) {
|
|
3
19
|
this.tools = [];
|
|
20
|
+
this.description = config.description;
|
|
21
|
+
this.context = config.context;
|
|
4
22
|
}
|
|
5
23
|
addTool(tool) {
|
|
24
|
+
// Validate the tool name before adding it
|
|
25
|
+
assertValidToolName(tool.name);
|
|
6
26
|
this.tools.push(tool);
|
|
7
27
|
}
|
|
8
28
|
async run(input) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -53,6 +53,15 @@ export interface ApiKeyResponse {
|
|
|
53
53
|
apiId: string;
|
|
54
54
|
}
|
|
55
55
|
import { ZodType } from "zod";
|
|
56
|
+
/**
|
|
57
|
+
* Validates that a tool name contains only alphanumeric characters, hyphens, and underscores.
|
|
58
|
+
* No spaces or other special characters are allowed.
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateToolName(name: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Throws an error if the tool name is invalid
|
|
63
|
+
*/
|
|
64
|
+
export declare function assertValidToolName(name: string): void;
|
|
56
65
|
export interface LuaTool<TInput extends ZodType = ZodType, TOutput extends ZodType = ZodType> {
|
|
57
66
|
name: string;
|
|
58
67
|
description: string;
|
|
@@ -60,10 +69,15 @@ export interface LuaTool<TInput extends ZodType = ZodType, TOutput extends ZodTy
|
|
|
60
69
|
outputSchema: TOutput;
|
|
61
70
|
execute: (input: any) => Promise<any>;
|
|
62
71
|
}
|
|
72
|
+
export interface LuaSkillConfig {
|
|
73
|
+
description: string;
|
|
74
|
+
context: string;
|
|
75
|
+
}
|
|
63
76
|
export declare class LuaSkill {
|
|
64
|
-
private readonly apiKey;
|
|
65
77
|
private readonly tools;
|
|
66
|
-
|
|
78
|
+
private readonly description;
|
|
79
|
+
private readonly context;
|
|
80
|
+
constructor(config: LuaSkillConfig);
|
|
67
81
|
addTool<TInput extends ZodType, TOutput extends ZodType>(tool: LuaTool<TInput, TOutput>): void;
|
|
68
82
|
run(input: Record<string, any>): Promise<any>;
|
|
69
83
|
}
|
package/dist/types/index.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Validates that a tool name contains only alphanumeric characters, hyphens, and underscores.
|
|
3
|
+
* No spaces or other special characters are allowed.
|
|
4
|
+
*/
|
|
5
|
+
export function validateToolName(name) {
|
|
6
|
+
const validNameRegex = /^[a-zA-Z0-9_-]+$/;
|
|
7
|
+
return validNameRegex.test(name);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Throws an error if the tool name is invalid
|
|
11
|
+
*/
|
|
12
|
+
export function assertValidToolName(name) {
|
|
13
|
+
if (!validateToolName(name)) {
|
|
14
|
+
throw new Error(`Invalid tool name "${name}". Tool names can only contain alphanumeric characters, hyphens (-), and underscores (_). No spaces or other special characters are allowed.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized CLI utilities for consistent error handling and output management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a command function with standardized error handling
|
|
6
|
+
* Handles SIGINT (Ctrl+C) gracefully and provides consistent error messages
|
|
7
|
+
*/
|
|
8
|
+
export declare function withErrorHandling<T>(commandFn: () => Promise<T>, commandName: string): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Clears the specified number of lines from the terminal
|
|
11
|
+
* Used to clean up inquirer prompt output ONLY
|
|
12
|
+
* Should NOT be used to clear user input commands
|
|
13
|
+
*/
|
|
14
|
+
export declare function clearPromptLines(count?: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Writes a progress message that will be replaced by the next message
|
|
17
|
+
* Uses carriage return to overwrite the current line
|
|
18
|
+
*/
|
|
19
|
+
export declare function writeProgress(message: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Writes a final success message that will remain visible
|
|
22
|
+
* Uses console.log to ensure it stays in the output
|
|
23
|
+
*/
|
|
24
|
+
export declare function writeSuccess(message: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Writes an error message
|
|
27
|
+
* Uses console.error for proper error output
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeError(message: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Writes an info message
|
|
32
|
+
* Uses console.log for informational output
|
|
33
|
+
*/
|
|
34
|
+
export declare function writeInfo(message: string): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized CLI utilities for consistent error handling and output management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a command function with standardized error handling
|
|
6
|
+
* Handles SIGINT (Ctrl+C) gracefully and provides consistent error messages
|
|
7
|
+
*/
|
|
8
|
+
export async function withErrorHandling(commandFn, commandName) {
|
|
9
|
+
try {
|
|
10
|
+
return await commandFn();
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.name === 'ExitPromptError') {
|
|
14
|
+
console.log("\n❌ Operation cancelled.");
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
console.error(`❌ Error during ${commandName}:`, error.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Clears the specified number of lines from the terminal
|
|
23
|
+
* Used to clean up inquirer prompt output ONLY
|
|
24
|
+
* Should NOT be used to clear user input commands
|
|
25
|
+
*/
|
|
26
|
+
export function clearPromptLines(count = 1) {
|
|
27
|
+
for (let i = 0; i < count; i++) {
|
|
28
|
+
process.stdout.write('\x1b[1A\x1b[2K'); // Move up 1 line and clear it
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Writes a progress message that will be replaced by the next message
|
|
33
|
+
* Uses carriage return to overwrite the current line
|
|
34
|
+
*/
|
|
35
|
+
export function writeProgress(message) {
|
|
36
|
+
process.stdout.write(`${message}\r`);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Writes a final success message that will remain visible
|
|
40
|
+
* Uses console.log to ensure it stays in the output
|
|
41
|
+
*/
|
|
42
|
+
export function writeSuccess(message) {
|
|
43
|
+
console.log(message);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Writes an error message
|
|
47
|
+
* Uses console.error for proper error output
|
|
48
|
+
*/
|
|
49
|
+
export function writeError(message) {
|
|
50
|
+
console.error(message);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Writes an info message
|
|
54
|
+
* Uses console.log for informational output
|
|
55
|
+
*/
|
|
56
|
+
export function writeInfo(message) {
|
|
57
|
+
console.log(message);
|
|
58
|
+
}
|
package/dist/utils/files.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function copyTemplateFiles(templateDir: string, targetDir: string): void;
|
|
2
|
-
export declare function createSkillToml(agentId: string, orgId: string, skillName: string,
|
|
2
|
+
export declare function createSkillToml(agentId: string, orgId: string, skillName: string, skillId?: string): void;
|
package/dist/utils/files.js
CHANGED
|
@@ -39,14 +39,15 @@ function updatePackageJson(srcPath, destPath) {
|
|
|
39
39
|
// Write the updated package.json
|
|
40
40
|
fs.writeFileSync(destPath, JSON.stringify(templatePackageJson, null, 2) + '\n');
|
|
41
41
|
}
|
|
42
|
-
export function createSkillToml(agentId, orgId, skillName,
|
|
42
|
+
export function createSkillToml(agentId, orgId, skillName, skillId) {
|
|
43
|
+
const skillIdSection = skillId ? `skillId = "${skillId}"\n` : '';
|
|
43
44
|
const tomlContent = `[agent]
|
|
44
45
|
agentId = "${agentId}"
|
|
45
46
|
orgId = "${orgId}"
|
|
46
47
|
|
|
47
48
|
[skill]
|
|
48
49
|
name = "${skillName}"
|
|
49
|
-
|
|
50
|
-
`;
|
|
50
|
+
version = "0.0.1"
|
|
51
|
+
${skillIdSection}`;
|
|
51
52
|
fs.writeFileSync("lua.skill.toml", tomlContent);
|
|
52
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.1",
|
|
4
4
|
"description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "rm -rf dist",
|
|
14
|
-
"build": "npm run clean && tsc",
|
|
14
|
+
"build": "npm run clean && tsc && chmod +x dist/index.js && npm link",
|
|
15
15
|
"prepublishOnly": "npm run build",
|
|
16
16
|
"test": "jest",
|
|
17
17
|
"test:watch": "jest --watch",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"deployment",
|
|
33
33
|
"skills"
|
|
34
34
|
],
|
|
35
|
-
"author": "Stefan Kruger <stefan@
|
|
35
|
+
"author": "Stefan Kruger <stefan@lua.dev>",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"type": "module",
|
|
38
38
|
"repository": {
|