@rudderhq/cli 0.3.6-canary.36 → 0.3.6-canary.37

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/index.js CHANGED
@@ -7466,6 +7466,15 @@ function isMaintainerOnlySkillTarget(candidate) {
7466
7466
  const normalized = normalizePathSlashes(candidate);
7467
7467
  return normalized.includes("/server/resources/bundled-skills/") || normalized.includes("/.agents/skills/");
7468
7468
  }
7469
+ function parseObject(value) {
7470
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
7471
+ return {};
7472
+ }
7473
+ return value;
7474
+ }
7475
+ function asString(value, fallback) {
7476
+ return typeof value === "string" && value.length > 0 ? value : fallback;
7477
+ }
7469
7478
 
7470
7479
  // ../packages/agent-runtime-utils/dist/server-utils.prompts.js
7471
7480
  var RUDDER_AGENT_OPERATING_CONTRACT = [
@@ -7577,25 +7586,48 @@ async function resolveRudderSkillsDir(moduleDir, additionalCandidates = []) {
7577
7586
  return null;
7578
7587
  }
7579
7588
  async function removeMaintainerOnlySkillSymlinks(skillsHome, allowedSkillNames) {
7589
+ return removeUnselectedRudderSkillSymlinks(skillsHome, allowedSkillNames);
7590
+ }
7591
+ async function readRudderMaterializedSkillSource(target) {
7592
+ const manifestPath = path9.join(target, ".rudder", "materialized-skill.json");
7593
+ const raw = await fs6.readFile(manifestPath, "utf8").catch(() => null);
7594
+ if (!raw)
7595
+ return null;
7596
+ try {
7597
+ const parsed = parseObject(JSON.parse(raw));
7598
+ const sourcePath = asString(parsed.sourcePath, "").trim();
7599
+ return sourcePath.length > 0 ? path9.resolve(sourcePath) : null;
7600
+ } catch {
7601
+ return null;
7602
+ }
7603
+ }
7604
+ async function removeUnselectedRudderSkillSymlinks(skillsHome, allowedSkillNames, knownSkillSources = []) {
7580
7605
  const allowed = new Set(Array.from(allowedSkillNames));
7606
+ const knownSources = new Set(Array.from(knownSkillSources).map((value) => value.trim()).filter(Boolean).map((value) => path9.resolve(value)));
7581
7607
  try {
7582
7608
  const entries = await fs6.readdir(skillsHome, { withFileTypes: true });
7583
7609
  const removed = [];
7584
7610
  for (const entry of entries) {
7585
- if (allowed.has(entry.name))
7586
- continue;
7587
7611
  const target = path9.join(skillsHome, entry.name);
7588
7612
  const existing = await fs6.lstat(target).catch(() => null);
7589
- if (!existing?.isSymbolicLink())
7613
+ if (!existing)
7590
7614
  continue;
7591
- const linkedPath = await fs6.readlink(target).catch(() => null);
7592
- if (!linkedPath)
7615
+ let isRudderManagedSkill = false;
7616
+ if (existing.isSymbolicLink()) {
7617
+ const linkedPath = await fs6.readlink(target).catch(() => null);
7618
+ if (!linkedPath)
7619
+ continue;
7620
+ const resolvedLinkedPath = path9.isAbsolute(linkedPath) ? linkedPath : path9.resolve(path9.dirname(target), linkedPath);
7621
+ isRudderManagedSkill = knownSources.has(path9.resolve(resolvedLinkedPath)) || isMaintainerOnlySkillTarget(linkedPath) || isMaintainerOnlySkillTarget(resolvedLinkedPath);
7622
+ } else if (existing.isDirectory()) {
7623
+ const materializedSource = await readRudderMaterializedSkillSource(target);
7624
+ isRudderManagedSkill = materializedSource !== null && knownSources.has(materializedSource);
7625
+ }
7626
+ if (!isRudderManagedSkill)
7593
7627
  continue;
7594
- const resolvedLinkedPath = path9.isAbsolute(linkedPath) ? linkedPath : path9.resolve(path9.dirname(target), linkedPath);
7595
- if (!isMaintainerOnlySkillTarget(linkedPath) && !isMaintainerOnlySkillTarget(resolvedLinkedPath)) {
7628
+ if (allowed.has(entry.name))
7596
7629
  continue;
7597
- }
7598
- await fs6.unlink(target);
7630
+ await fs6.rm(target, { recursive: true, force: true });
7599
7631
  removed.push(entry.name);
7600
7632
  }
7601
7633
  return removed;