@alessandroraffa/tangyr 3.0.1 → 3.0.3

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 (2) hide show
  1. package/dist/index.js +121 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16114,6 +16114,12 @@ function addManagedLink(manifest, link) {
16114
16114
  manifest.managedLinks.push(link);
16115
16115
  }
16116
16116
  }
16117
+ function parkConflictingPath(destination, scopePath) {
16118
+ const backupPath = resolveBackupPath(destination, scopePath);
16119
+ fs6.mkdirSync(path6.dirname(backupPath), { recursive: true });
16120
+ fs6.renameSync(destination, backupPath);
16121
+ return backupPath;
16122
+ }
16117
16123
 
16118
16124
  // src/core/exit.ts
16119
16125
  var EXIT_FAILURE = 1;
@@ -17323,6 +17329,18 @@ function collectAssessFindings(scope, projectRoot, toolFilter, assessOptions) {
17323
17329
  scope,
17324
17330
  scope === "project" ? projectRoot ?? process.cwd() : void 0
17325
17331
  );
17332
+ const recorded = recordedArtifactPaths(scopePath);
17333
+ for (const finding of findings) {
17334
+ if (finding.classification !== "conflicting") {
17335
+ continue;
17336
+ }
17337
+ const resolved = path12.resolve(finding.path);
17338
+ const ours = recorded.has(resolved) || finding.type === "directory" && holdsOnlyRecorded(resolved, recorded);
17339
+ if (ours) {
17340
+ finding.classification = "compatible";
17341
+ finding.description = `${finding.description} (recorded by this installation)`;
17342
+ }
17343
+ }
17326
17344
  if (fs11.existsSync(path12.join(scopePath, "manifest.json"))) {
17327
17345
  findings.push({
17328
17346
  path: path12.join(scopePath, "manifest.json"),
@@ -17518,6 +17536,49 @@ function resolveKitPath(config, configDir) {
17518
17536
  });
17519
17537
  return resolution?.kit.path ?? null;
17520
17538
  }
17539
+ function recordedArtifactPaths(scopePath) {
17540
+ const paths = /* @__PURE__ */ new Set();
17541
+ try {
17542
+ const manifest = readManifest(scopePath);
17543
+ if (!manifest) {
17544
+ return paths;
17545
+ }
17546
+ for (const artifact of manifest.artifacts) {
17547
+ if (artifact.path) {
17548
+ paths.add(path12.resolve(artifact.path));
17549
+ }
17550
+ }
17551
+ for (const link of manifest.managedLinks) {
17552
+ paths.add(path12.resolve(link.path));
17553
+ }
17554
+ } catch {
17555
+ }
17556
+ return paths;
17557
+ }
17558
+ function holdsOnlyRecorded(dir, recorded) {
17559
+ let entries;
17560
+ try {
17561
+ entries = fs11.readdirSync(dir, { withFileTypes: true });
17562
+ } catch {
17563
+ return false;
17564
+ }
17565
+ if (entries.length === 0) {
17566
+ return [...recorded].some((p) => p.startsWith(`${dir}${path12.sep}`));
17567
+ }
17568
+ for (const entry of entries) {
17569
+ const full = path12.join(dir, entry.name);
17570
+ if (entry.isDirectory() && !entry.isSymbolicLink()) {
17571
+ if (!holdsOnlyRecorded(full, recorded)) {
17572
+ return false;
17573
+ }
17574
+ continue;
17575
+ }
17576
+ if (!recorded.has(full)) {
17577
+ return false;
17578
+ }
17579
+ }
17580
+ return true;
17581
+ }
17521
17582
 
17522
17583
  // src/commands/auth.ts
17523
17584
  import fs14 from "fs";
@@ -26858,7 +26919,16 @@ function handleConflict(destination, config, options, logger, manifest, scopePat
26858
26919
  writeManifest(scopePath, manifest);
26859
26920
  fs37.rmSync(destination, { recursive: true, force: true });
26860
26921
  } else {
26861
- fs37.renameSync(destination, `${destination}.bak.${Date.now()}`);
26922
+ const parked = parkConflictingPath(
26923
+ destination,
26924
+ resolveScopePath(
26925
+ options.scope ?? "global",
26926
+ options.scope === "project" ? options.projectRoot : void 0
26927
+ )
26928
+ );
26929
+ logger.warn(
26930
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
26931
+ );
26862
26932
  }
26863
26933
  return true;
26864
26934
  }
@@ -28760,7 +28830,16 @@ function handleConflict2(destination, config, options, logger, manifest, scopePa
28760
28830
  writeManifest(scopePath, manifest);
28761
28831
  fs39.rmSync(destination, { recursive: true, force: true });
28762
28832
  } else {
28763
- fs39.renameSync(destination, `${destination}.bak.${Date.now()}`);
28833
+ const parked = parkConflictingPath(
28834
+ destination,
28835
+ resolveScopePath(
28836
+ options.scope ?? "global",
28837
+ options.scope === "project" ? options.projectRoot : void 0
28838
+ )
28839
+ );
28840
+ logger.warn(
28841
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
28842
+ );
28764
28843
  }
28765
28844
  return true;
28766
28845
  }
@@ -29353,7 +29432,16 @@ function handleConflict3(destination, config, options, logger, manifest, scopePa
29353
29432
  writeManifest(scopePath, manifest);
29354
29433
  fs40.rmSync(destination, { recursive: true, force: true });
29355
29434
  } else {
29356
- fs40.renameSync(destination, `${destination}.bak.${Date.now()}`);
29435
+ const parked = parkConflictingPath(
29436
+ destination,
29437
+ resolveScopePath(
29438
+ options.scope ?? "global",
29439
+ options.scope === "project" ? options.projectRoot : void 0
29440
+ )
29441
+ );
29442
+ logger.warn(
29443
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
29444
+ );
29357
29445
  }
29358
29446
  return true;
29359
29447
  }
@@ -29985,7 +30073,16 @@ function handleConflict4(destination, config, options, logger, manifest, scopePa
29985
30073
  writeManifest(scopePath, manifest);
29986
30074
  fs41.rmSync(destination, { recursive: true, force: true });
29987
30075
  } else {
29988
- fs41.renameSync(destination, `${destination}.bak.${Date.now()}`);
30076
+ const parked = parkConflictingPath(
30077
+ destination,
30078
+ resolveScopePath(
30079
+ options.scope ?? "global",
30080
+ options.scope === "project" ? options.projectRoot : void 0
30081
+ )
30082
+ );
30083
+ logger.warn(
30084
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
30085
+ );
29989
30086
  }
29990
30087
  return true;
29991
30088
  }
@@ -30466,7 +30563,16 @@ function handleConflict5(destination, config, options, logger, manifest, scopePa
30466
30563
  writeManifest(scopePath, manifest);
30467
30564
  fs42.rmSync(destination, { recursive: true, force: true });
30468
30565
  } else {
30469
- fs42.renameSync(destination, `${destination}.bak.${Date.now()}`);
30566
+ const parked = parkConflictingPath(
30567
+ destination,
30568
+ resolveScopePath(
30569
+ options.scope ?? "global",
30570
+ options.scope === "project" ? options.projectRoot : void 0
30571
+ )
30572
+ );
30573
+ logger.warn(
30574
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
30575
+ );
30470
30576
  }
30471
30577
  return true;
30472
30578
  }
@@ -30965,7 +31071,16 @@ function handleConflict6(destination, config, options, logger, manifest, scopePa
30965
31071
  writeManifest(scopePath, manifest);
30966
31072
  fs43.rmSync(destination, { recursive: true, force: true });
30967
31073
  } else {
30968
- fs43.renameSync(destination, `${destination}.bak.${Date.now()}`);
31074
+ const parked = parkConflictingPath(
31075
+ destination,
31076
+ resolveScopePath(
31077
+ options.scope ?? "global",
31078
+ options.scope === "project" ? options.projectRoot : void 0
31079
+ )
31080
+ );
31081
+ logger.warn(
31082
+ `${destination}: moved to ${parked} (unrecorded: this run has no manifest to note it in, so uninstall will not restore it)`
31083
+ );
30969
31084
  }
30970
31085
  return true;
30971
31086
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alessandroraffa/tangyr",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "CLI for the Tangyr discipline — install and manage operating kits for AI coding tools",
5
5
  "license": "MIT",
6
6
  "engines": {