@bacano/sdk 1.2.6 → 1.2.8

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.
@@ -6,6 +6,7 @@ import {
6
6
  existsSync,
7
7
  lstatSync,
8
8
  mkdirSync,
9
+ readdirSync,
9
10
  readFileSync,
10
11
  readlinkSync,
11
12
  rmSync,
@@ -17,7 +18,6 @@ import { fileURLToPath } from "node:url";
17
18
 
18
19
  const scriptDirectory = dirname(fileURLToPath(import.meta.url));
19
20
  const sourceSkill = resolve(scriptDirectory, "..");
20
- const sourceSkillFile = resolve(sourceSkill, "SKILL.md");
21
21
  const projectRoot = process.cwd();
22
22
  const canonicalSkill = resolve(projectRoot, ".agents", "skills", "bacano-web");
23
23
 
@@ -43,8 +43,27 @@ function option(name) {
43
43
  return index >= 0 ? process.argv[index + 1] : null;
44
44
  }
45
45
 
46
- function hash(file) {
47
- return createHash("sha256").update(readFileSync(file)).digest("hex");
46
+ function skillFingerprint(directory) {
47
+ const digest = createHash("sha256");
48
+
49
+ function visit(current, prefix = "") {
50
+ for (const entry of readdirSync(current, { withFileTypes: true }).sort(
51
+ (first, second) => first.name.localeCompare(second.name),
52
+ )) {
53
+ const name = prefix ? `${prefix}/${entry.name}` : entry.name;
54
+ const path = resolve(current, entry.name);
55
+ if (entry.isDirectory()) {
56
+ visit(path, name);
57
+ } else if (entry.isFile()) {
58
+ digest.update(name).update("\0").update(readFileSync(path));
59
+ } else if (entry.isSymbolicLink()) {
60
+ digest.update(name).update("\0").update(readlinkSync(path));
61
+ }
62
+ }
63
+ }
64
+
65
+ visit(directory);
66
+ return digest.digest("hex");
48
67
  }
49
68
 
50
69
  function skillFile(directory) {
@@ -70,7 +89,8 @@ function installCanonical(force) {
70
89
  if (resolve(sourceSkill) === canonicalSkill) return;
71
90
 
72
91
  if (existsSync(skillFile(canonicalSkill))) {
73
- if (hash(skillFile(canonicalSkill)) === hash(sourceSkillFile)) return;
92
+ if (skillFingerprint(canonicalSkill) === skillFingerprint(sourceSkill))
93
+ return;
74
94
  removeExisting(canonicalSkill, force);
75
95
  } else if (existsSync(canonicalSkill)) {
76
96
  removeExisting(canonicalSkill, force);
@@ -170,7 +190,10 @@ function checkPath(name, path) {
170
190
  return {
171
191
  name,
172
192
  path: relativeDisplay(path),
173
- status: hash(file) === hash(sourceSkillFile) ? "current" : "outdated",
193
+ status:
194
+ skillFingerprint(path) === skillFingerprint(sourceSkill)
195
+ ? "current"
196
+ : "outdated",
174
197
  link: lstatSync(path).isSymbolicLink(),
175
198
  };
176
199
  }