lua-cli 3.0.2-alpha.4 → 3.0.2-alpha.5

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.
@@ -75,6 +75,7 @@ async function bundleAndCompressExecuteFunction(executeFunction, componentName,
75
75
  }
76
76
  const tempFile = path.join(tempDir, `${componentName}-${componentType}.ts`);
77
77
  const tempOutput = path.join(tempDir, `${componentName}-${componentType}.js`);
78
+ let moduleCode = ''; // Declare outside try block for debug mode access
78
79
  try {
79
80
  // Extract relevant imports from source file
80
81
  const relevantImports = extractRelevantImports(sourceFilePath);
@@ -85,7 +86,7 @@ async function bundleAndCompressExecuteFunction(executeFunction, componentName,
85
86
  }
86
87
  }
87
88
  // Write execute function as a module export with all relevant imports
88
- const moduleCode = `
89
+ moduleCode = `
89
90
  // ${componentType} execute function for ${componentName}
90
91
  ${relevantImports.join('\n')}
91
92
 
@@ -94,13 +95,18 @@ const executeFunc = ${executeFunction};
94
95
 
95
96
  export default executeFunc;
96
97
  `;
97
- fs.writeFileSync(tempFile, moduleCode);
98
98
  if (debugMode) {
99
- console.log(` → Created temp file: ${path.basename(tempFile)}`);
99
+ console.log(` → Using stdin bundling to preserve import resolution`);
100
100
  }
101
- // Bundle with esbuild using the source file's directory for import resolution
101
+ // Bundle with esbuild using stdin to preserve import resolution
102
+ // This ensures relative imports resolve correctly from the original source file location
102
103
  await build({
103
- entryPoints: [tempFile],
104
+ stdin: {
105
+ contents: moduleCode,
106
+ resolveDir: path.dirname(sourceFilePath), // Resolve imports from source file's directory
107
+ sourcefile: sourceFilePath, // Pretend we're the source file for better error messages
108
+ loader: 'ts',
109
+ },
104
110
  bundle: true,
105
111
  platform: 'node',
106
112
  target: 'node16',
@@ -109,7 +115,6 @@ export default executeFunc;
109
115
  outfile: tempOutput,
110
116
  external: [...EXTERNAL_PACKAGES], // Use same external packages as tools
111
117
  plugins: [sandboxGlobalsPlugin],
112
- absWorkingDir: path.dirname(sourceFilePath), // Use source file's directory for resolution
113
118
  });
114
119
  // Read bundled code and validate it exists and has content
115
120
  if (!fs.existsSync(tempOutput)) {
@@ -130,7 +135,6 @@ export default executeFunc;
130
135
  // Clean up temp files (unless in debug mode)
131
136
  if (!debugMode) {
132
137
  try {
133
- fs.unlinkSync(tempFile);
134
138
  fs.unlinkSync(tempOutput);
135
139
  }
136
140
  catch (cleanupError) {
@@ -138,9 +142,11 @@ export default executeFunc;
138
142
  }
139
143
  }
140
144
  else {
145
+ // In debug mode, write the moduleCode to tempFile for inspection
146
+ fs.writeFileSync(tempFile, moduleCode);
141
147
  console.log(` ℹ️ Preserved temp files for debugging:`);
142
- console.log(` - ${tempFile}`);
143
- console.log(` - ${tempOutput}`);
148
+ console.log(` - ${tempFile} (source with imports)`);
149
+ console.log(` - ${tempOutput} (bundled output)`);
144
150
  }
145
151
  return compressed;
146
152
  }
@@ -149,7 +155,14 @@ export default executeFunc;
149
155
  let errorMessage = `Warning: Could not bundle ${componentType} ${componentName}`;
150
156
  if (error.message && error.message.includes('Could not resolve')) {
151
157
  errorMessage += `\n Dependency resolution failed: ${error.message}`;
152
- errorMessage += `\n Hint: Ensure all imported packages are in package.json and run 'npm install'`;
158
+ // Check if it's a relative import issue
159
+ if (error.message.includes('"../') || error.message.includes('"./')) {
160
+ errorMessage += `\n Hint: Relative imports detected. Consider using TypeScript path aliases (e.g., @/services/...)`;
161
+ errorMessage += `\n Or ensure the import path is correct relative to: ${path.dirname(sourceFilePath)}`;
162
+ }
163
+ else {
164
+ errorMessage += `\n Hint: Ensure all imported packages are in package.json and run 'npm install'`;
165
+ }
153
166
  }
154
167
  else if (error.message && error.message.includes('Transform failed')) {
155
168
  errorMessage += `\n TypeScript compilation failed: ${error.message}`;
@@ -165,8 +178,6 @@ export default executeFunc;
165
178
  // Clean up on error (unless in debug mode)
166
179
  if (!debugMode) {
167
180
  try {
168
- if (fs.existsSync(tempFile))
169
- fs.unlinkSync(tempFile);
170
181
  if (fs.existsSync(tempOutput))
171
182
  fs.unlinkSync(tempOutput);
172
183
  }
@@ -175,7 +186,14 @@ export default executeFunc;
175
186
  }
176
187
  }
177
188
  else {
178
- console.log(` ℹ️ Temp files preserved for debugging (check dist/.temp/)`);
189
+ // In debug mode, write the moduleCode for inspection
190
+ try {
191
+ fs.writeFileSync(tempFile, moduleCode);
192
+ console.log(` ℹ️ Temp files preserved for debugging (check dist/.temp/)`);
193
+ }
194
+ catch (writeError) {
195
+ // Ignore write errors
196
+ }
179
197
  }
180
198
  return '';
181
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lua-cli",
3
- "version": "3.0.2-alpha.4",
3
+ "version": "3.0.2-alpha.5",
4
4
  "description": "Build, test, and deploy AI agents with custom tools, webhooks, and scheduled jobs. Features LuaAgent unified configuration, streaming chat, and batch deployment.",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "dist/api-exports.js",
@@ -1,5 +1,5 @@
1
1
  import { LuaSkill } from "lua-cli";
2
- import { CreateInlineJobTool, GetUserDataTool, UpdateUserDataTool, WritePoemTool } from "./tools/UserDataTool";
2
+ import { CreateInlineJobTool, GetUserDataTool, UpdateUserDataTool, WritePoemTool } from "../skills/tools/UserDataTool";
3
3
 
4
4
 
5
5
  const userSkill = new LuaSkill({