@cleocode/caamp 0.4.0 → 0.4.1

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/cli.js CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  RECOMMENDATION_ERROR_CODES,
5
5
  applyMcpInstallWithPolicy,
6
6
  buildServerConfig,
7
+ buildSkillSubPathCandidates,
7
8
  checkAllInjections,
8
9
  checkSkillUpdate,
9
10
  configureProviderGlobalAndProject,
@@ -40,6 +41,9 @@ import {
40
41
  removeSkill,
41
42
  removeSkillFromLock,
42
43
  resolveConfigPath,
44
+ resolvePreferredConfigScope,
45
+ resolveProviderConfigPath,
46
+ resolveProviderSkillsDir,
43
47
  scanDirectory,
44
48
  scanFile,
45
49
  selectProvidersByMinimumPriority,
@@ -49,7 +53,7 @@ import {
49
53
  tokenizeCriteriaValue,
50
54
  updateInstructionsSingleOperation,
51
55
  validateSkill
52
- } from "./chunk-ZYINKJDE.js";
56
+ } from "./chunk-6HQDRJLS.js";
53
57
 
54
58
  // src/cli.ts
55
59
  import { Command } from "commander";
@@ -204,28 +208,6 @@ async function cloneGitLabRepo(owner, repo, ref, subPath) {
204
208
  }
205
209
 
206
210
  // src/commands/skills/install.ts
207
- function normalizeSkillSubPath(path) {
208
- if (!path) return void 0;
209
- const normalized = path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/SKILL\.md$/i, "").trim();
210
- return normalized.length > 0 ? normalized : void 0;
211
- }
212
- function marketplacePathCandidates(skillPath, parsedPath) {
213
- const candidates = [];
214
- const base = normalizeSkillSubPath(skillPath);
215
- const parsed = normalizeSkillSubPath(parsedPath);
216
- if (base) candidates.push(base);
217
- if (parsed) candidates.push(parsed);
218
- if (base && base.startsWith("skills/") && !base.startsWith(".claude/")) {
219
- candidates.push(`.claude/${base}`);
220
- }
221
- if (parsed && parsed.startsWith("skills/") && !parsed.startsWith(".claude/")) {
222
- candidates.push(`.claude/${parsed}`);
223
- }
224
- if (candidates.length === 0) {
225
- candidates.push(void 0);
226
- }
227
- return Array.from(new Set(candidates));
228
- }
229
211
  function registerSkillsInstall(parent) {
230
212
  parent.command("install").description("Install a skill from GitHub, URL, or marketplace").argument("<source>", "Skill source (GitHub URL, owner/repo, @author/name)").option("-a, --agent <name>", "Target specific agent(s)", (v, prev) => [...prev, v], []).option("-g, --global", "Install globally").option("-y, --yes", "Skip confirmation").option("--all", "Install to all detected agents").action(async (source, opts) => {
231
213
  let providers;
@@ -267,7 +249,7 @@ function registerSkillsInstall(parent) {
267
249
  process.exit(1);
268
250
  }
269
251
  try {
270
- const subPathCandidates = marketplacePathCandidates(skill.path, parsed.path);
252
+ const subPathCandidates = buildSkillSubPathCandidates(skill.path, parsed.path);
271
253
  let cloneError;
272
254
  let cloned = false;
273
255
  for (const subPath of subPathCandidates) {
@@ -397,7 +379,6 @@ function registerSkillsRemove(parent) {
397
379
 
398
380
  // src/commands/skills/list.ts
399
381
  import pc4 from "picocolors";
400
- import { join as join3 } from "path";
401
382
  function registerSkillsList(parent) {
402
383
  parent.command("list").description("List installed skills").option("-g, --global", "List global skills").option("-a, --agent <name>", "List skills for specific agent").option("--json", "Output as JSON").action(async (opts) => {
403
384
  let dirs = [];
@@ -407,13 +388,13 @@ function registerSkillsList(parent) {
407
388
  console.error(pc4.red(`Provider not found: ${opts.agent}`));
408
389
  process.exit(1);
409
390
  }
410
- dirs = opts.global ? [provider.pathSkills] : [join3(process.cwd(), provider.pathProjectSkills)];
391
+ dirs = opts.global ? [resolveProviderSkillsDir(provider, "global")] : [resolveProviderSkillsDir(provider, "project")];
411
392
  } else if (opts.global) {
412
393
  const providers = getInstalledProviders();
413
- dirs = providers.map((p) => p.pathSkills).filter(Boolean);
394
+ dirs = providers.map((p) => resolveProviderSkillsDir(p, "global")).filter(Boolean);
414
395
  } else {
415
396
  const providers = getInstalledProviders();
416
- dirs = providers.map((p) => join3(process.cwd(), p.pathProjectSkills)).filter(Boolean);
397
+ dirs = providers.map((p) => resolveProviderSkillsDir(p, "project")).filter(Boolean);
417
398
  }
418
399
  const skills = await discoverSkillsMulti(dirs);
419
400
  if (opts.json) {
@@ -864,11 +845,11 @@ ${outdated.length} skill(s) have updates available:
864
845
  import pc8 from "picocolors";
865
846
  import { writeFile, mkdir } from "fs/promises";
866
847
  import { existsSync as existsSync2 } from "fs";
867
- import { join as join4 } from "path";
848
+ import { join as join3 } from "path";
868
849
  function registerSkillsInit(parent) {
869
850
  parent.command("init").description("Create a new SKILL.md template").argument("[name]", "Skill name").option("-d, --dir <path>", "Output directory", ".").action(async (name, opts) => {
870
851
  const skillName = name ?? "my-skill";
871
- const skillDir = join4(opts.dir, skillName);
852
+ const skillDir = join3(opts.dir, skillName);
872
853
  if (existsSync2(skillDir)) {
873
854
  console.error(pc8.red(`Directory already exists: ${skillDir}`));
874
855
  process.exit(1);
@@ -897,11 +878,11 @@ Provide detailed instructions for the AI agent here.
897
878
 
898
879
  Show example inputs and expected outputs.
899
880
  `;
900
- await writeFile(join4(skillDir, "SKILL.md"), template, "utf-8");
881
+ await writeFile(join3(skillDir, "SKILL.md"), template, "utf-8");
901
882
  console.log(pc8.green(`\u2713 Created skill template: ${skillDir}/SKILL.md`));
902
883
  console.log(pc8.dim("\nNext steps:"));
903
884
  console.log(pc8.dim(" 1. Edit SKILL.md with your instructions"));
904
- console.log(pc8.dim(" 2. Validate: caamp skills validate " + join4(skillDir, "SKILL.md")));
885
+ console.log(pc8.dim(" 2. Validate: caamp skills validate " + join3(skillDir, "SKILL.md")));
905
886
  console.log(pc8.dim(" 3. Install: caamp skills install " + skillDir));
906
887
  });
907
888
  }
@@ -1101,7 +1082,7 @@ function registerMcpList(parent) {
1101
1082
  const providers = opts.agent ? [getProvider(opts.agent)].filter((p) => p !== void 0) : getInstalledProviders();
1102
1083
  const allEntries = [];
1103
1084
  for (const provider of providers) {
1104
- const scope = opts.global ? "global" : provider.configPathProject ? "project" : "global";
1085
+ const scope = resolvePreferredConfigScope(provider, opts.global);
1105
1086
  const entries = await listMcpServers(provider, scope);
1106
1087
  allEntries.push(...entries);
1107
1088
  }
@@ -1302,7 +1283,6 @@ function registerInstructionsCommands(program2) {
1302
1283
 
1303
1284
  // src/commands/config.ts
1304
1285
  import pc18 from "picocolors";
1305
- import { join as join5 } from "path";
1306
1286
  import { existsSync as existsSync5 } from "fs";
1307
1287
  function registerConfigCommand(program2) {
1308
1288
  const config = program2.command("config").description("View provider configuration");
@@ -1312,7 +1292,10 @@ function registerConfigCommand(program2) {
1312
1292
  console.error(pc18.red(`Provider not found: ${providerId}`));
1313
1293
  process.exit(1);
1314
1294
  }
1315
- const configPath = opts.global ? provider.configPathGlobal : provider.configPathProject ? join5(process.cwd(), provider.configPathProject) : provider.configPathGlobal;
1295
+ const configPath = resolveProviderConfigPath(
1296
+ provider,
1297
+ opts.global ? "global" : "project"
1298
+ ) ?? provider.configPathGlobal;
1316
1299
  if (!existsSync5(configPath)) {
1317
1300
  console.log(pc18.dim(`No config file at: ${configPath}`));
1318
1301
  return;
@@ -1341,8 +1324,9 @@ ${provider.toolName} config (${configPath}):
1341
1324
  if (scope === "global") {
1342
1325
  console.log(provider.configPathGlobal);
1343
1326
  } else {
1344
- if (provider.configPathProject) {
1345
- console.log(join5(process.cwd(), provider.configPathProject));
1327
+ const projectPath = resolveProviderConfigPath(provider, "project");
1328
+ if (projectPath) {
1329
+ console.log(projectPath);
1346
1330
  } else {
1347
1331
  console.log(pc18.dim(`${provider.toolName} has no project-level config`));
1348
1332
  console.log(provider.configPathGlobal);
@@ -1356,7 +1340,7 @@ import pc19 from "picocolors";
1356
1340
  import { execFileSync } from "child_process";
1357
1341
  import { existsSync as existsSync6, readdirSync, lstatSync } from "fs";
1358
1342
  import { homedir } from "os";
1359
- import { join as join6 } from "path";
1343
+ import { join as join4 } from "path";
1360
1344
  var CAAMP_VERSION = "0.2.0";
1361
1345
  function getNodeVersion() {
1362
1346
  return process.version;
@@ -1432,7 +1416,7 @@ function checkInstalledProviders() {
1432
1416
  }
1433
1417
  function checkSkillSymlinks() {
1434
1418
  const checks = [];
1435
- const canonicalDir = join6(homedir(), ".agents", "skills");
1419
+ const canonicalDir = join4(homedir(), ".agents", "skills");
1436
1420
  if (!existsSync6(canonicalDir)) {
1437
1421
  checks.push({ label: "0 canonical skills", status: "pass" });
1438
1422
  checks.push({ label: "No broken symlinks", status: "pass" });
@@ -1455,7 +1439,7 @@ function checkSkillSymlinks() {
1455
1439
  try {
1456
1440
  const entries = readdirSync(skillDir);
1457
1441
  for (const entry of entries) {
1458
- const fullPath = join6(skillDir, entry);
1442
+ const fullPath = join4(skillDir, entry);
1459
1443
  try {
1460
1444
  const stat = lstatSync(fullPath);
1461
1445
  if (stat.isSymbolicLink()) {