lua-cli 1.3.0-alpha.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.
- 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/dist/utils/files.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import
|
|
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
|
|
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,15 +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
|
|
43
|
-
const skillIdSection = skillId ? `skillId
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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"
|
|
51
53
|
${skillIdSection}`;
|
|
52
|
-
fs.writeFileSync("lua.skill.
|
|
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 || ''}"
|
|
92
|
+
|
|
93
|
+
skill:
|
|
94
|
+
name: "${data.skill.name}"
|
|
95
|
+
version: "${data.skill.version}"
|
|
96
|
+
skillId: "${data.skill.skillId || ''}"
|
|
97
|
+
`;
|
|
98
|
+
fs.writeFileSync(yamlPath, updatedYamlContent);
|
|
53
99
|
}
|