add-skill 1.0.27 → 1.0.29

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 +51 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1056,7 +1056,6 @@ registerProvider(huggingFaceProvider);
1056
1056
  import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
1057
1057
  import { join as join5, dirname as dirname2 } from "path";
1058
1058
  import { homedir as homedir3 } from "os";
1059
- import { createHash } from "crypto";
1060
1059
  var AGENTS_DIR2 = ".agents";
1061
1060
  var LOCK_FILE = ".skill-lock.json";
1062
1061
  var CURRENT_VERSION = 3;
@@ -1071,11 +1070,8 @@ async function readSkillLock() {
1071
1070
  if (typeof parsed.version !== "number" || !parsed.skills) {
1072
1071
  return createEmptyLockFile();
1073
1072
  }
1074
- if (parsed.version < 2) {
1075
- return createEmptyLockFile();
1076
- }
1077
1073
  if (parsed.version < CURRENT_VERSION) {
1078
- parsed.version = CURRENT_VERSION;
1074
+ return createEmptyLockFile();
1079
1075
  }
1080
1076
  return parsed;
1081
1077
  } catch (error) {
@@ -1088,8 +1084,39 @@ async function writeSkillLock(lock) {
1088
1084
  const content = JSON.stringify(lock, null, 2);
1089
1085
  await writeFile2(lockPath, content, "utf-8");
1090
1086
  }
1091
- function computeContentHash(content) {
1092
- return createHash("sha256").update(content, "utf-8").digest("hex");
1087
+ async function fetchSkillFolderHash(ownerRepo, skillPath) {
1088
+ let folderPath = skillPath;
1089
+ if (folderPath.endsWith("/SKILL.md")) {
1090
+ folderPath = folderPath.slice(0, -9);
1091
+ } else if (folderPath.endsWith("SKILL.md")) {
1092
+ folderPath = folderPath.slice(0, -8);
1093
+ }
1094
+ if (folderPath.endsWith("/")) {
1095
+ folderPath = folderPath.slice(0, -1);
1096
+ }
1097
+ const branches = ["main", "master"];
1098
+ for (const branch of branches) {
1099
+ try {
1100
+ const url = `https://api.github.com/repos/${ownerRepo}/git/trees/${branch}?recursive=1`;
1101
+ const response = await fetch(url, {
1102
+ headers: {
1103
+ "Accept": "application/vnd.github.v3+json",
1104
+ "User-Agent": "add-skill-cli"
1105
+ }
1106
+ });
1107
+ if (!response.ok) continue;
1108
+ const data = await response.json();
1109
+ const folderEntry = data.tree.find(
1110
+ (entry) => entry.type === "tree" && entry.path === folderPath
1111
+ );
1112
+ if (folderEntry) {
1113
+ return folderEntry.sha;
1114
+ }
1115
+ } catch {
1116
+ continue;
1117
+ }
1118
+ }
1119
+ return null;
1093
1120
  }
1094
1121
  async function addSkillToLock(skillName, entry) {
1095
1122
  const lock = await readSkillLock();
@@ -1112,7 +1139,7 @@ function createEmptyLockFile() {
1112
1139
  // package.json
1113
1140
  var package_default = {
1114
1141
  name: "add-skill",
1115
- version: "1.0.27",
1142
+ version: "1.0.29",
1116
1143
  description: "Install agent skills onto coding agents (OpenCode, Claude Code, Codex, Cursor)",
1117
1144
  type: "module",
1118
1145
  bin: {
@@ -1467,13 +1494,16 @@ async function handleRemoteSkill(source, url, options, spinner2) {
1467
1494
  });
1468
1495
  if (successful.length > 0 && installGlobally) {
1469
1496
  try {
1470
- const contentHash = computeContentHash(remoteSkill.content);
1497
+ let skillFolderHash = "";
1498
+ if (remoteSkill.providerId === "github") {
1499
+ const hash = await fetchSkillFolderHash(remoteSkill.sourceIdentifier, url);
1500
+ if (hash) skillFolderHash = hash;
1501
+ }
1471
1502
  await addSkillToLock(remoteSkill.installName, {
1472
1503
  source: remoteSkill.sourceIdentifier,
1473
1504
  sourceType: remoteSkill.providerId,
1474
1505
  sourceUrl: url,
1475
- contentHash
1476
- // skillFolderHash will be populated by server during update check
1506
+ skillFolderHash
1477
1507
  });
1478
1508
  } catch {
1479
1509
  }
@@ -1727,13 +1757,12 @@ async function handleDirectUrlSkillLegacy(source, url, options, spinner2) {
1727
1757
  });
1728
1758
  if (successful.length > 0 && installGlobally) {
1729
1759
  try {
1730
- const contentHash = computeContentHash(mintlifySkill.content);
1731
1760
  await addSkillToLock(mintlifySkill.mintlifySite, {
1732
1761
  source: `mintlify/${mintlifySkill.mintlifySite}`,
1733
1762
  sourceType: "mintlify",
1734
1763
  sourceUrl: url,
1735
- contentHash
1736
- // skillFolderHash will be populated by server during update check
1764
+ skillFolderHash: ""
1765
+ // Populated by server
1737
1766
  });
1738
1767
  } catch {
1739
1768
  }
@@ -2105,13 +2134,18 @@ async function main(source, options) {
2105
2134
  const skillDisplayName = getSkillDisplayName(skill);
2106
2135
  if (successfulSkillNames.has(skillDisplayName)) {
2107
2136
  try {
2137
+ let skillFolderHash = "";
2138
+ const skillPathValue = skillFiles[skill.name];
2139
+ if (parsed.type === "github" && skillPathValue) {
2140
+ const hash = await fetchSkillFolderHash(normalizedSource, skillPathValue);
2141
+ if (hash) skillFolderHash = hash;
2142
+ }
2108
2143
  await addSkillToLock(skill.name, {
2109
2144
  source: normalizedSource,
2110
2145
  sourceType: parsed.type,
2111
2146
  sourceUrl: parsed.url,
2112
- skillPath: skillFiles[skill.name],
2113
- contentHash: skill.rawContent ? computeContentHash(skill.rawContent) : ""
2114
- // skillFolderHash is populated by server via GitHub Trees API
2147
+ skillPath: skillPathValue,
2148
+ skillFolderHash
2115
2149
  });
2116
2150
  } catch {
2117
2151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-skill",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Install agent skills onto coding agents (OpenCode, Claude Code, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "bin": {