lua-cli 1.2.0 → 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/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
- constructor();
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
- constructor() {
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) {
@@ -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
- constructor(apiKey: string);
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
  }
@@ -1 +1,16 @@
1
- export {};
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
+ }
@@ -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, skillDescription: string): void;
2
+ export declare function createSkillToml(agentId: string, orgId: string, skillName: string, skillId?: string): void;
@@ -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, skillDescription) {
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
- description = "${skillDescription}"
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.2.0",
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@heylua.ai>",
35
+ "author": "Stefan Kruger <stefan@lua.dev>",
36
36
  "license": "MIT",
37
37
  "type": "module",
38
38
  "repository": {
@@ -56,6 +56,7 @@
56
56
  ],
57
57
  "dependencies": {
58
58
  "commander": "^14.0.1",
59
+ "esbuild": "^0.25.10",
59
60
  "inquirer": "^12.9.6",
60
61
  "keytar": "^7.9.0",
61
62
  "node-fetch": "^3.3.2",
@@ -66,7 +67,6 @@
66
67
  "@types/jest": "^29.5.8",
67
68
  "@types/node": "^24.5.1",
68
69
  "@types/node-fetch": "^2.6.13",
69
- "esbuild": "^0.25.10",
70
70
  "jest": "^29.7.0",
71
71
  "ts-jest": "^29.1.1",
72
72
  "ts-node": "^10.9.2",
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "version": "1.0.1-beta.0",
3
3
  "skillsName": "lua-skill",
4
+ "skillId": "",
5
+ "description": "A comprehensive Lua skill with weather, user data, post creation, and mathematical tools",
6
+ "context": "This skill provides various utilities including weather information, user data retrieval, post creation, basic calculator operations, and advanced mathematical functions. Use get_weather to fetch current weather conditions for any city, get_user_data to retrieve user information, create_post to publish new posts, calculator for basic arithmetic operations, and advanced_math for complex mathematical computations like factorials, prime checking, fibonacci sequences, and greatest common divisor calculations.",
4
7
  "tools": [
5
8
  {
6
9
  "name": "get_weather",
package/template/index.ts CHANGED
@@ -6,7 +6,10 @@ import CalculatorTool from "./tools/CalculatorTool";
6
6
  import AdvancedMathTool from "./tools/AdvancedMathTool";
7
7
 
8
8
  // Initialize skill with tools
9
- const skill = new LuaSkill();
9
+ const skill = new LuaSkill({
10
+ description: "A comprehensive Lua skill with weather, user data, post creation, and mathematical tools",
11
+ context: "This skill provides various utilities including weather information, user data retrieval, post creation, basic calculator operations, and advanced mathematical functions. Use get_weather to fetch current weather conditions for any city, get_user_data to retrieve user information, create_post to publish new posts, calculator for basic arithmetic operations, and advanced_math for complex mathematical computations like factorials, prime checking, fibonacci sequences, and greatest common divisor calculations."
12
+ });
10
13
  skill.addTool(new GetWeatherTool());
11
14
  skill.addTool(new GetUserDataTool());
12
15
  skill.addTool(new CreatePostTool());
@@ -30,7 +30,7 @@ export default class AdvancedMathTool implements LuaTool<typeof inputSchema, typ
30
30
  this.mathService = new MathService();
31
31
  }
32
32
 
33
- async execute(input) {
33
+ async execute(input: z.infer<typeof inputSchema>) {
34
34
  let result: any;
35
35
 
36
36
  switch (input.operation) {
@@ -28,7 +28,7 @@ export default class CalculatorTool implements LuaTool<typeof inputSchema, typeo
28
28
  this.outputSchema = outputSchema;
29
29
  }
30
30
 
31
- async execute(input) {
31
+ async execute(input: z.infer<typeof inputSchema>) {
32
32
  let result: number;
33
33
  let expression: string;
34
34