lua-cli 1.2.1 → 1.3.0

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 (55) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +244 -63
  3. package/dist/commands/agents.js +17 -17
  4. package/dist/commands/apiKey.js +24 -19
  5. package/dist/commands/compile.d.ts +1 -0
  6. package/dist/commands/compile.js +1004 -0
  7. package/dist/commands/configure.js +93 -68
  8. package/dist/commands/deploy-new.d.ts +0 -0
  9. package/dist/commands/deploy-new.js +130 -0
  10. package/dist/commands/deploy.d.ts +19 -0
  11. package/dist/commands/deploy.js +81 -763
  12. package/dist/commands/destroy.js +26 -21
  13. package/dist/commands/dev.d.ts +63 -0
  14. package/dist/commands/dev.js +656 -0
  15. package/dist/commands/index.d.ts +4 -2
  16. package/dist/commands/index.js +4 -2
  17. package/dist/commands/init.js +297 -62
  18. package/dist/commands/push.d.ts +22 -0
  19. package/dist/commands/push.js +127 -0
  20. package/dist/commands/test.js +14 -15
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +35 -19
  23. package/dist/services/api.d.ts +195 -0
  24. package/dist/services/api.js +209 -0
  25. package/dist/services/auth.d.ts +102 -0
  26. package/dist/services/auth.js +129 -40
  27. package/dist/skill.d.ts +22 -1
  28. package/dist/skill.js +21 -1
  29. package/dist/types/index.d.ts +16 -2
  30. package/dist/types/index.js +16 -1
  31. package/dist/user-data-api.d.ts +52 -0
  32. package/dist/user-data-api.js +151 -0
  33. package/dist/utils/cli.d.ts +34 -0
  34. package/dist/utils/cli.js +58 -0
  35. package/dist/utils/files.d.ts +4 -1
  36. package/dist/utils/files.js +61 -14
  37. package/dist/web/app.css +1050 -0
  38. package/dist/web/app.js +79 -0
  39. package/dist/web/tools-page.css +377 -0
  40. package/package.json +18 -5
  41. package/template/package-lock.json +32 -3
  42. package/template/package.json +3 -1
  43. package/template/{index.ts → src/index.ts} +13 -4
  44. package/template/src/tools/UserPreferencesTool.ts +73 -0
  45. package/template/tools/UserPreferencesTool.ts +73 -0
  46. package/template/tsconfig.json +1 -1
  47. package/template/.lua/deploy.json +0 -145
  48. /package/template/{services → src/services}/ApiService.ts +0 -0
  49. /package/template/{services → src/services}/GetWeather.ts +0 -0
  50. /package/template/{services → src/services}/MathService.ts +0 -0
  51. /package/template/{tools → src/tools}/AdvancedMathTool.ts +0 -0
  52. /package/template/{tools → src/tools}/CalculatorTool.ts +0 -0
  53. /package/template/{tools → src/tools}/CreatePostTool.ts +0 -0
  54. /package/template/{tools → src/tools}/GetUserDataTool.ts +0 -0
  55. /package/template/{tools → src/tools}/GetWeatherTool.ts +0 -0
@@ -1,6 +1,7 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { fileURLToPath } from "url";
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import pkg from 'js-yaml';
4
+ const { load } = pkg;
4
5
  export function copyTemplateFiles(templateDir, targetDir) {
5
6
  const files = fs.readdirSync(templateDir);
6
7
  for (const file of files) {
@@ -27,9 +28,7 @@ function updatePackageJson(srcPath, destPath) {
27
28
  // Read the template package.json
28
29
  const templatePackageJson = JSON.parse(fs.readFileSync(srcPath, 'utf8'));
29
30
  // Get the current CLI version from the main package.json
30
- const __filename = fileURLToPath(import.meta.url);
31
- const __dirname = path.dirname(__filename);
32
- const mainPackageJsonPath = path.join(__dirname, '..', '..', 'package.json');
31
+ const mainPackageJsonPath = path.join(process.cwd(), 'package.json');
33
32
  const mainPackageJson = JSON.parse(fs.readFileSync(mainPackageJsonPath, 'utf8'));
34
33
  const currentCliVersion = mainPackageJson.version;
35
34
  // Update the lua-cli dependency version
@@ -39,14 +38,62 @@ function updatePackageJson(srcPath, destPath) {
39
38
  // Write the updated package.json
40
39
  fs.writeFileSync(destPath, JSON.stringify(templatePackageJson, null, 2) + '\n');
41
40
  }
42
- export function createSkillToml(agentId, orgId, skillName, skillDescription) {
43
- const tomlContent = `[agent]
44
- agentId = "${agentId}"
45
- orgId = "${orgId}"
41
+ export function createSkillYaml(agentId, orgId, skillName, skillId, persona, welcomeMessage) {
42
+ const skillIdSection = skillId ? ` skillId: "${skillId}"\n` : '';
43
+ // Handle multiline strings properly for YAML
44
+ const personaSection = persona ? ` persona: |\n${persona.split('\n').map(line => ` ${line}`).join('\n')}\n` : '';
45
+ const welcomeMessageSection = welcomeMessage ? ` welcomeMessage: "${welcomeMessage}"\n` : '';
46
+ const yamlContent = `agent:
47
+ agentId: "${agentId}"
48
+ orgId: "${orgId}"
49
+ ${personaSection}${welcomeMessageSection}
50
+ skill:
51
+ name: "${skillName}"
52
+ version: "0.0.1"
53
+ ${skillIdSection}`;
54
+ fs.writeFileSync("lua.skill.yaml", yamlContent);
55
+ }
56
+ export function readSkillYaml() {
57
+ const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
58
+ if (!fs.existsSync(yamlPath)) {
59
+ return null;
60
+ }
61
+ const yamlContent = fs.readFileSync(yamlPath, 'utf8');
62
+ return load(yamlContent);
63
+ }
64
+ export function readSkillConfig() {
65
+ // Read YAML config file
66
+ return readSkillYaml();
67
+ }
68
+ export function updateSkillYamlPersona(persona, welcomeMessage) {
69
+ const yamlPath = path.join(process.cwd(), 'lua.skill.yaml');
70
+ if (!fs.existsSync(yamlPath)) {
71
+ console.error('❌ No lua.skill.yaml found. Please run this command from a skill directory.');
72
+ return;
73
+ }
74
+ const yamlContent = fs.readFileSync(yamlPath, 'utf8');
75
+ const data = load(yamlContent);
76
+ // Update persona
77
+ if (!data.agent) {
78
+ data.agent = {};
79
+ }
80
+ data.agent.persona = persona;
81
+ // Update welcome message if provided
82
+ if (welcomeMessage) {
83
+ data.agent.welcomeMessage = welcomeMessage;
84
+ }
85
+ // Convert back to YAML with proper formatting
86
+ const updatedYamlContent = `agent:
87
+ agentId: "${data.agent.agentId}"
88
+ orgId: "${data.agent.orgId}"
89
+ persona: |
90
+ ${persona.split('\n').map(line => ` ${line}`).join('\n')}
91
+ welcomeMessage: "${data.agent.welcomeMessage || ''}"
46
92
 
47
- [skill]
48
- name = "${skillName}"
49
- description = "${skillDescription}"
93
+ skill:
94
+ name: "${data.skill.name}"
95
+ version: "${data.skill.version}"
96
+ skillId: "${data.skill.skillId || ''}"
50
97
  `;
51
- fs.writeFileSync("lua.skill.toml", tomlContent);
98
+ fs.writeFileSync(yamlPath, updatedYamlContent);
52
99
  }