@codemcp/skills 2.0.0 → 2.1.0

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/api.js ADDED
@@ -0,0 +1,23 @@
1
+ import {
2
+ addSkillToLocalLock,
3
+ computeSkillFolderHash,
4
+ getLocalLockPath,
5
+ parseAddOptions,
6
+ readLocalLock,
7
+ removeSkillFromLocalLock,
8
+ runAdd,
9
+ runInstallFromLock,
10
+ writeLocalLock
11
+ } from "./chunk-US7NTYE7.js";
12
+ import "./chunk-JSBRDJBE.js";
13
+ export {
14
+ addSkillToLocalLock,
15
+ computeSkillFolderHash,
16
+ getLocalLockPath,
17
+ parseAddOptions,
18
+ readLocalLock,
19
+ removeSkillFromLocalLock,
20
+ runAdd,
21
+ runInstallFromLock,
22
+ writeLocalLock
23
+ };
@@ -0,0 +1,30 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ export {
28
+ __commonJS,
29
+ __toESM
30
+ };
@@ -1,29 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
1
  // ../core/dist/config-generators.js
28
2
  var ConfigGeneratorRegistry = class {
29
3
  generators = /* @__PURE__ */ new Map();
@@ -1166,226 +1140,12 @@ var SkillRegistry = class {
1166
1140
  }
1167
1141
  };
1168
1142
 
1169
- // ../core/dist/package-config.js
1143
+ // ../core/dist/skills-lock.js
1170
1144
  import { promises as fs3 } from "fs";
1171
1145
  import { join as join2 } from "path";
1172
- var PackageConfigManager = class {
1173
- projectRoot;
1174
- packageJsonPath;
1175
- constructor(projectRoot) {
1176
- if (!projectRoot) {
1177
- throw new Error("Project root directory is required");
1178
- }
1179
- this.projectRoot = projectRoot;
1180
- this.packageJsonPath = join2(projectRoot, "package.json");
1181
- }
1182
- /**
1183
- * Get default configuration with empty skills and standard defaults
1184
- */
1185
- getDefaultConfig() {
1186
- return {
1187
- skills: {},
1188
- config: {
1189
- skillsDirectory: ".agentskills/skills",
1190
- autoDiscover: [".claude/skills"],
1191
- maxSkillSize: 5e3,
1192
- logLevel: "info"
1193
- },
1194
- source: {
1195
- type: "defaults"
1196
- }
1197
- };
1198
- }
1199
- /**
1200
- * Load configuration from package.json
1201
- * Returns defaults if package.json doesn't exist
1202
- */
1203
- async loadConfig() {
1204
- try {
1205
- const content = await fs3.readFile(this.packageJsonPath, "utf-8");
1206
- let packageJson;
1207
- try {
1208
- packageJson = JSON.parse(content);
1209
- } catch (error) {
1210
- throw new Error(`Failed to parse package.json: ${error instanceof Error ? error.message : String(error)}`);
1211
- }
1212
- const skills = this.validateAndExtractSkills(packageJson);
1213
- const config = this.validateAndExtractConfig(packageJson);
1214
- return {
1215
- skills,
1216
- config,
1217
- source: {
1218
- type: "file",
1219
- path: this.packageJsonPath
1220
- }
1221
- };
1222
- } catch (error) {
1223
- if (error.code === "ENOENT") {
1224
- return this.getDefaultConfig();
1225
- }
1226
- if (error.code === "EACCES") {
1227
- throw new Error(`Permission denied reading package.json at ${this.packageJsonPath}`);
1228
- }
1229
- throw error;
1230
- }
1231
- }
1232
- /**
1233
- * Validate and extract skills from package.json
1234
- */
1235
- validateAndExtractSkills(packageJson) {
1236
- if (!packageJson.agentskills) {
1237
- return {};
1238
- }
1239
- const agentskills = packageJson.agentskills;
1240
- if (typeof agentskills !== "object" || agentskills === null || Array.isArray(agentskills)) {
1241
- throw new Error("agentskills must be an object");
1242
- }
1243
- for (const value of Object.values(agentskills)) {
1244
- if (typeof value !== "string") {
1245
- throw new Error("agentskills values must be strings");
1246
- }
1247
- }
1248
- return agentskills;
1249
- }
1250
- /**
1251
- * Validate and extract config from package.json
1252
- */
1253
- validateAndExtractConfig(packageJson) {
1254
- const defaultConfig = this.getDefaultConfig().config;
1255
- if (!packageJson.agentskillsConfig) {
1256
- return defaultConfig;
1257
- }
1258
- const agentskillsConfig = packageJson.agentskillsConfig;
1259
- if (typeof agentskillsConfig !== "object" || agentskillsConfig === null || Array.isArray(agentskillsConfig)) {
1260
- throw new Error("agentskillsConfig must be an object");
1261
- }
1262
- const configObj = agentskillsConfig;
1263
- const config = { ...defaultConfig };
1264
- if (configObj.skillsDirectory !== void 0) {
1265
- if (typeof configObj.skillsDirectory !== "string") {
1266
- throw new Error("skillsDirectory must be a string");
1267
- }
1268
- if (configObj.skillsDirectory === "") {
1269
- throw new Error("skillsDirectory cannot be empty");
1270
- }
1271
- config.skillsDirectory = configObj.skillsDirectory;
1272
- }
1273
- if (configObj.autoDiscover !== void 0) {
1274
- if (!Array.isArray(configObj.autoDiscover)) {
1275
- throw new Error("autoDiscover must be an array");
1276
- }
1277
- for (const item of configObj.autoDiscover) {
1278
- if (typeof item !== "string") {
1279
- throw new Error("autoDiscover must contain only strings");
1280
- }
1281
- }
1282
- config.autoDiscover = configObj.autoDiscover;
1283
- }
1284
- if (configObj.maxSkillSize !== void 0) {
1285
- if (typeof configObj.maxSkillSize !== "number") {
1286
- throw new Error("maxSkillSize must be a number");
1287
- }
1288
- if (configObj.maxSkillSize <= 0) {
1289
- throw new Error("maxSkillSize must be a positive number");
1290
- }
1291
- config.maxSkillSize = configObj.maxSkillSize;
1292
- }
1293
- if (configObj.logLevel !== void 0) {
1294
- if (typeof configObj.logLevel !== "string") {
1295
- throw new Error("logLevel must be a string");
1296
- }
1297
- const validLogLevels = ["error", "warn", "info", "debug"];
1298
- if (!validLogLevels.includes(configObj.logLevel)) {
1299
- throw new Error(`Invalid logLevel '${configObj.logLevel}'. Must be one of: error, warn, info, debug`);
1300
- }
1301
- config.logLevel = configObj.logLevel;
1302
- }
1303
- return config;
1304
- }
1305
- /**
1306
- * Save skills to package.json
1307
- * Creates package.json if it doesn't exist
1308
- * Preserves other fields
1309
- */
1310
- async saveSkills(skills) {
1311
- let packageJson;
1312
- try {
1313
- const content = await fs3.readFile(this.packageJsonPath, "utf-8");
1314
- packageJson = JSON.parse(content);
1315
- } catch (error) {
1316
- if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
1317
- packageJson = {
1318
- name: "agentskills-project"
1319
- };
1320
- } else {
1321
- throw error;
1322
- }
1323
- }
1324
- packageJson.agentskills = skills;
1325
- await fs3.writeFile(this.packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
1326
- }
1327
- /**
1328
- * Add a single skill to package.json
1329
- * Updates existing skill if name already exists
1330
- */
1331
- async addSkill(name, spec) {
1332
- if (!name) {
1333
- throw new Error("Skill name cannot be empty");
1334
- }
1335
- if (!spec) {
1336
- throw new Error("Skill spec cannot be empty");
1337
- }
1338
- let packageJson;
1339
- try {
1340
- const content = await fs3.readFile(this.packageJsonPath, "utf-8");
1341
- packageJson = JSON.parse(content);
1342
- } catch (error) {
1343
- if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
1344
- packageJson = {
1345
- name: "agentskills-project"
1346
- };
1347
- } else {
1348
- throw error;
1349
- }
1350
- }
1351
- if (!packageJson.agentskills) {
1352
- packageJson.agentskills = {};
1353
- }
1354
- const agentskills = packageJson.agentskills;
1355
- agentskills[name] = spec;
1356
- await fs3.writeFile(this.packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
1357
- }
1358
- /**
1359
- * Remove a skill from package.json
1360
- * Does not error if skill doesn't exist or file doesn't exist
1361
- */
1362
- async removeSkill(name) {
1363
- if (!name) {
1364
- throw new Error("Skill name cannot be empty");
1365
- }
1366
- try {
1367
- const content = await fs3.readFile(this.packageJsonPath, "utf-8");
1368
- const packageJson = JSON.parse(content);
1369
- if (!packageJson.agentskills) {
1370
- return;
1371
- }
1372
- delete packageJson.agentskills[name];
1373
- await fs3.writeFile(this.packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
1374
- } catch (error) {
1375
- if (error.code === "ENOENT") {
1376
- return;
1377
- }
1378
- throw error;
1379
- }
1380
- }
1381
- };
1382
-
1383
- // ../core/dist/skills-lock.js
1384
- import { promises as fs4 } from "fs";
1385
- import { join as join3 } from "path";
1386
1146
  async function loadSkillsLock(lockFilePath) {
1387
1147
  try {
1388
- const content = await fs4.readFile(lockFilePath, "utf-8");
1148
+ const content = await fs3.readFile(lockFilePath, "utf-8");
1389
1149
  const lock = JSON.parse(content);
1390
1150
  return lock;
1391
1151
  } catch (error) {
@@ -1403,11 +1163,11 @@ async function getAllowedSkills(lockFilePath) {
1403
1163
  return new Set(Object.keys(lock.skills));
1404
1164
  }
1405
1165
  async function getAllowedSkillsFromProject(projectDir) {
1406
- const lockFilePath = join3(projectDir, "skills-lock.json");
1166
+ const lockFilePath = join2(projectDir, "skills-lock.json");
1407
1167
  return getAllowedSkills(lockFilePath);
1408
1168
  }
1409
1169
  async function getAllowedSkillsFromAgentskills(projectDir) {
1410
- const lockFilePath = join3(projectDir, "skills-lock.json");
1170
+ const lockFilePath = join2(projectDir, "skills-lock.json");
1411
1171
  return getAllowedSkills(lockFilePath);
1412
1172
  }
1413
1173
 
@@ -1513,8 +1273,6 @@ var McpConfigAdapterRegistry = class {
1513
1273
  McpConfigAdapterRegistry.initialize();
1514
1274
 
1515
1275
  export {
1516
- __commonJS,
1517
- __toESM,
1518
1276
  ConfigGeneratorRegistry,
1519
1277
  GitHubCopilotGenerator,
1520
1278
  KiroGenerator,
@@ -1525,7 +1283,6 @@ export {
1525
1283
  parseSkill,
1526
1284
  validateSkill,
1527
1285
  SkillRegistry,
1528
- PackageConfigManager,
1529
1286
  loadSkillsLock,
1530
1287
  getAllowedSkills,
1531
1288
  getAllowedSkillsFromProject,