@mgamadeus/ddd-web 0.19.2 → 0.19.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.3
4
+
5
+ ### Fixed
6
+ - `ddd-web link-skills` (and the Composer twin `ddd-link-skills` of `mgamadeus/ddd`) linked a skill from a nested,
7
+ older copy of a package (a second npm or Composer root below the repository) because the copies were ordered by
8
+ path. The copy whose install folder lies closest to the repository root (the app's own install) now wins, at the
9
+ same depth the higher version; the skipped copy is printed as a `copy` note (not a problem, `--check` passes).
10
+
3
11
  ## 0.19.2
4
12
 
5
13
  ### Fixed
package/README.md CHANGED
@@ -283,7 +283,9 @@ postinstall never fight; either one alone links everything.
283
283
  lies at most three levels below the root (`vendor/`, `app/vendor/`, `apps/admin/node_modules/`); other `vendor/`,
284
284
  `node_modules/` and dot folders are not searched, symlinked folders are not followed. A skill is a folder with a
285
285
  `SKILL.md`. Order: skill path, byte order. The same name from two packages is a clash: the first is kept and the
286
- clash reported. The same package installed twice (two Composer roots) is not a clash.
286
+ clash reported. The same package installed twice (two Composer or npm roots) is not a clash: the copy whose install folder lies closest
287
+ to the root (the app's own install) is linked, at the same depth the higher version; the skipped copy is reported as a
288
+ note (`copy`), not a problem.
287
289
  3. **Primary folder** `<root>/.claude/skills`, created when missing. When `.claude` or `.claude/skills` is a symlink
288
290
  (for example to `.codex`), the links go into its real location, once.
289
291
  4. **Mirrors** `<root>/.agents/skills` and `<root>/.codex/skills` (Codex): the layout is detected, never changed. A
@@ -2941,6 +2941,7 @@ var SkillLinker = class {
2941
2941
  }
2942
2942
  }
2943
2943
  for (const warning of plan.warnings) this.warn(warning);
2944
+ for (const note of plan.notes) this.info(note);
2944
2945
  const skillCount = plan.managedSkillNames.length;
2945
2946
  const packageCount = plan.packageNames.length;
2946
2947
  const changeCount = plan.operations.length;
@@ -2971,7 +2972,7 @@ var SkillLinker = class {
2971
2972
  const primary = this.resolvePrimaryDirectory();
2972
2973
  const primaryExists = isDirectory(primaryLogical);
2973
2974
  if (!primaryExists && winners.size === 0) {
2974
- return { nothingToDo: true, operations: [], warnings: [], managedSkillNames: [], packageNames: [] };
2975
+ return { nothingToDo: true, operations: [], warnings: [], notes: [], managedSkillNames: [], packageNames: [] };
2975
2976
  }
2976
2977
  const previousManifestPath = `${primary}/${SKILLS_MANIFEST_FILE_NAME}`;
2977
2978
  let previousEntries = readManifestEntries(previousManifestPath);
@@ -3135,11 +3136,12 @@ var SkillLinker = class {
3135
3136
  }
3136
3137
  const packageNames = /* @__PURE__ */ new Set();
3137
3138
  for (const entry of managed.values()) if (typeof entry.package === "string") packageNames.add(entry.package);
3138
- return { nothingToDo: false, operations, warnings, managedSkillNames: managedNames, packageNames: [...packageNames] };
3139
+ return { nothingToDo: false, operations, warnings, notes: discovery.notes, managedSkillNames: managedNames, packageNames: [...packageNames] };
3139
3140
  }
3140
3141
  /**
3141
3142
  * Skills of all DDD packages below the root in deterministic order (skill path, byte order). The first package
3142
- * shipping a name wins; another package with the same name is a clash; the same package installed twice is not.
3143
+ * shipping a name wins; another package with the same name is a clash; the same package installed twice is not: the
3144
+ * copy closest to the root wins, then the higher version ({@link isPreferredCopyOverOther}); the skipped copy is a note.
3143
3145
  */
3144
3146
  discoverSkills() {
3145
3147
  const candidates = [];
@@ -3155,18 +3157,39 @@ var SkillLinker = class {
3155
3157
  candidates.sort((first, second) => compareBytes(first.directory, second.directory));
3156
3158
  const winners = /* @__PURE__ */ new Map();
3157
3159
  const warnings = [];
3160
+ const notes = [];
3158
3161
  for (const candidate of candidates) {
3159
3162
  const winner = winners.get(candidate.name);
3160
3163
  if (!winner) {
3161
3164
  winners.set(candidate.name, candidate);
3162
- } else if (winner.package !== candidate.package) {
3165
+ } else if (winner.package === candidate.package) {
3166
+ const preferred = this.isPreferredCopyOverOther(candidate, winner) ? candidate : winner;
3167
+ const skipped = preferred === candidate ? winner : candidate;
3168
+ winners.set(candidate.name, preferred);
3169
+ notes.push(
3170
+ `${label("copy")}${candidate.name}: ${candidate.package} ${preferred.version ?? "?"} (${relativePath(this.root, preferred.directory)}) linked; the copy ${skipped.version ?? "?"} (${relativePath(this.root, skipped.directory)}) skipped`
3171
+ );
3172
+ } else {
3163
3173
  warnings.push(
3164
3174
  `${label("clash")}${candidate.name}: shipped by ${winner.package} (${relativePath(this.root, winner.directory)}) and ${candidate.package} (${relativePath(this.root, candidate.directory)}); ${winner.package} kept`
3165
3175
  );
3166
3176
  this.results.push({ skill: candidate.name, action: "skipped", target: relativePath(this.root, candidate.directory), package: candidate.package });
3167
3177
  }
3168
3178
  }
3169
- return { winners, warnings };
3179
+ return { winners, warnings, notes };
3180
+ }
3181
+ /**
3182
+ * Of two copies of the same package that ship one skill name (two Composer or npm roots below the repository), the
3183
+ * app's own install wins: the copy whose install folder lies closest to the root; at the same depth the higher
3184
+ * version; then the first in path order.
3185
+ */
3186
+ isPreferredCopyOverOther(copy, otherCopy) {
3187
+ const copyDepth = relativePath(this.root, copy.directory).split("/").length;
3188
+ const otherCopyDepth = relativePath(this.root, otherCopy.directory).split("/").length;
3189
+ if (copyDepth !== otherCopyDepth) return copyDepth < otherCopyDepth;
3190
+ const versionComparison = compareVersions(copy.version, otherCopy.version);
3191
+ if (versionComparison !== 0) return versionComparison > 0;
3192
+ return compareBytes(copy.directory, otherCopy.directory) < 0;
3170
3193
  }
3171
3194
  legacySourcePackage(sourceDir) {
3172
3195
  const skillsDirectory = path12.resolve(path12.resolve(this.options.cwd ?? process.cwd()), sourceDir);
@@ -3362,6 +3385,16 @@ function listDirectoryNames(directory) {
3362
3385
  return [];
3363
3386
  }
3364
3387
  }
3388
+ function compareVersions(first, second) {
3389
+ const partsOf = (version) => (version ?? "0").replace(/^v/, "").split(/[.+-]/).map((part) => /^\d+$/.test(part) ? Number(part) : 0);
3390
+ const firstParts = partsOf(first);
3391
+ const secondParts = partsOf(second);
3392
+ for (let index = 0; index < Math.max(firstParts.length, secondParts.length); index++) {
3393
+ const difference = (firstParts[index] ?? 0) - (secondParts[index] ?? 0);
3394
+ if (difference !== 0) return difference > 0 ? 1 : -1;
3395
+ }
3396
+ return 0;
3397
+ }
3365
3398
  function compareBytes(first, second) {
3366
3399
  return Buffer.compare(Buffer.from(first), Buffer.from(second));
3367
3400
  }
@@ -3396,4 +3429,4 @@ export {
3396
3429
  runSkillLinks,
3397
3430
  linkSkills
3398
3431
  };
3399
- //# sourceMappingURL=chunk-K3AQR2GB.js.map
3432
+ //# sourceMappingURL=chunk-IPOFLOAJ.js.map