@amaster.ai/cli 1.1.39 → 1.1.41

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/cli.cjs CHANGED
@@ -626,6 +626,9 @@ function validateMembers(manifest) {
626
626
  if (!resolveMemberSourcePath(member)) {
627
627
  throw new Error(`addon.json member ${member.name} missing source.path`);
628
628
  }
629
+ if (member.type === "settings" && resolveMemberTargetPath(member)) {
630
+ throw new Error(`Settings member ${member.name} does not support target.path`);
631
+ }
629
632
  }
630
633
  }
631
634
  function validateDisplayAssets(manifest) {
@@ -857,6 +860,13 @@ function resolveMemberSourcePath(member) {
857
860
  }
858
861
  return null;
859
862
  }
863
+ function resolveMemberTargetPath(member) {
864
+ const targetPath = member.target?.path;
865
+ if (typeof targetPath === "string" && targetPath.trim()) {
866
+ return normalizeRelativePath(targetPath, "member target path");
867
+ }
868
+ return null;
869
+ }
860
870
  function normalizeRelativePath(value, fieldName = "path") {
861
871
  if (path.isAbsolute(value)) {
862
872
  throw new Error(`Invalid addon.json ${fieldName}: ${value}`);
@@ -1179,7 +1189,9 @@ function buildAddonLlmGuidance(input) {
1179
1189
  instructions.push("Use installed function members by invoking their function names from the host application.");
1180
1190
  }
1181
1191
  if (hasInstallRequirements(input.requirements)) {
1182
- instructions.push("Configure the declared env/secret requirements before running or deploying the application.");
1192
+ instructions.push(
1193
+ "Configure the declared env/secret requirements before running or deploying the application. Use the app_secret_env tool instead of writing secret values into source files or .env examples."
1194
+ );
1183
1195
  }
1184
1196
  if (hasNpmDependencies(input.npm)) {
1185
1197
  instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
@@ -1290,6 +1302,11 @@ function isExistingNpmDependencyCompatible(existingVersion, requestedVersion) {
1290
1302
  }
1291
1303
  return semver.gte(existingMinimum, requestedMinimum);
1292
1304
  }
1305
+ function isSameOrInsidePath(path$1, parentPath) {
1306
+ const normalizedPath = path.resolve("/", path$1);
1307
+ const normalizedParent = path.resolve("/", parentPath);
1308
+ return normalizedPath === normalizedParent || normalizedPath.startsWith(`${normalizedParent}/`);
1309
+ }
1293
1310
  async function collectDirectoryFiles(sourceDir) {
1294
1311
  const entries = await promises$1.readdir(sourceDir, { withFileTypes: true });
1295
1312
  const files = [];
@@ -1303,16 +1320,18 @@ async function collectDirectoryFiles(sourceDir) {
1303
1320
  }
1304
1321
  return files.sort();
1305
1322
  }
1306
- async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member) {
1323
+ async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member, targetRelativePath) {
1307
1324
  const sourceAbsolutePath = path.join(sourceRoot, sourceRelativePath);
1308
1325
  const sourceStat = await promises$1.stat(sourceAbsolutePath);
1309
1326
  const plannedFiles = [];
1310
1327
  const targetPaths = [];
1328
+ const defaultTargetPath = path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
1329
+ const memberTargetPath = targetRelativePath ?? defaultTargetPath;
1311
1330
  if (sourceStat.isDirectory()) {
1312
1331
  const sourceFiles = await collectDirectoryFiles(sourceAbsolutePath);
1313
1332
  for (const sourceFile of sourceFiles) {
1314
1333
  const nestedRelativePath = path.relative(sourceAbsolutePath, sourceFile);
1315
- const targetPath = path.join(targetBaseRelativeDir, path.basename(sourceRelativePath), nestedRelativePath).replace(/\\/g, "/");
1334
+ const targetPath = path.join(memberTargetPath, nestedRelativePath).replace(/\\/g, "/");
1316
1335
  const sourcePackagePath = path.join(sourceRelativePath, nestedRelativePath).replace(/\\/g, "/");
1317
1336
  plannedFiles.push({
1318
1337
  sourcePath: sourceFile,
@@ -1324,7 +1343,7 @@ async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelative
1324
1343
  targetPaths.push(targetPath);
1325
1344
  }
1326
1345
  } else {
1327
- const targetPath = path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
1346
+ const targetPath = memberTargetPath;
1328
1347
  plannedFiles.push({
1329
1348
  sourcePath: sourceAbsolutePath,
1330
1349
  sourceRelativePath,
@@ -1408,7 +1427,19 @@ async function buildInstallPlan(options) {
1408
1427
  default:
1409
1428
  throw new Error(`Unsupported addon member type: ${member.type}`);
1410
1429
  }
1411
- const planned = await planCopyMember(options.extractedDir, sourceRelativePath, targetBaseRelativeDir, member);
1430
+ const targetRelativePath = resolveMemberTargetPath(member);
1431
+ if (targetRelativePath && !isSameOrInsidePath(targetRelativePath, targetBaseRelativeDir)) {
1432
+ throw new Error(
1433
+ `Member ${member.name} target.path must stay inside ${targetBaseRelativeDir}: ${targetRelativePath}`
1434
+ );
1435
+ }
1436
+ const planned = await planCopyMember(
1437
+ options.extractedDir,
1438
+ sourceRelativePath,
1439
+ targetBaseRelativeDir,
1440
+ member,
1441
+ targetRelativePath
1442
+ );
1412
1443
  files.push(...planned.files);
1413
1444
  const installedMember = {
1414
1445
  name: member.name,