@cleocode/caamp 2026.5.87 → 2026.5.89

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/index.js CHANGED
@@ -1,15 +1,11 @@
1
1
  import {
2
- AgentsSkillsRealDirError,
3
2
  DEFAULT_EXCLUSIVITY_MODE,
4
3
  EXCLUSIVITY_MODE_ENV_VAR,
5
4
  MarketplaceClient,
6
5
  PiHarness,
7
6
  PiRequiredError,
8
7
  RECOMMENDATION_ERROR_CODES,
9
- applyDecision,
10
- buildBackupTimestamp,
11
8
  buildLibraryFromFiles,
12
- caampStandaloneAdapters,
13
9
  catalog_exports,
14
10
  checkAllSkillUpdates,
15
11
  checkSkillUpdate,
@@ -19,7 +15,6 @@ import {
19
15
  detectMcpInstallations,
20
16
  detectProjectProviders,
21
17
  detectProvider,
22
- discoverOrphans,
23
18
  discoverSkill,
24
19
  discoverSkills,
25
20
  ensureDir,
@@ -53,7 +48,6 @@ import {
53
48
  recordSkillInstall,
54
49
  registerSkillLibrary,
55
50
  registerSkillLibraryFromPath,
56
- registerSkillsDoctorAdopt,
57
51
  removeConfig,
58
52
  removeMcpServer,
59
53
  removeMcpServerFromAll,
@@ -63,8 +57,6 @@ import {
63
57
  resetExclusivityModeOverride,
64
58
  resolveDefaultTargetProviders,
65
59
  resolveMcpConfigPath,
66
- runDoctorAdopt,
67
- runDoctorBridge,
68
60
  scanDirectory,
69
61
  scanFile,
70
62
  scoreSkillRecommendation,
@@ -78,9 +70,8 @@ import {
78
70
  updateInstructionsSingleOperation,
79
71
  validateRecommendationCriteria,
80
72
  validateSkill,
81
- writeAuditLog,
82
73
  writeConfig
83
- } from "./chunk-WXL7RPS4.js";
74
+ } from "./chunk-RTK4A3WY.js";
84
75
  import {
85
76
  buildInjectionContent,
86
77
  buildSkillsMap,
@@ -120,7 +111,7 @@ import {
120
111
  removeInjection,
121
112
  resolveAlias,
122
113
  writeAgentFileToAllProviders
123
- } from "./chunk-PGETUTYZ.js";
114
+ } from "./chunk-EH5U4PRC.js";
124
115
  import {
125
116
  CANONICAL_HOOK_EVENTS,
126
117
  HOOK_CATEGORIES,
@@ -146,9 +137,8 @@ import {
146
137
  toNative,
147
138
  toNativeBatch,
148
139
  translateToAll
149
- } from "./chunk-QKC2JRSG.js";
140
+ } from "./chunk-YCAANESR.js";
150
141
  import {
151
- _resetLegacySkillsWarning,
152
142
  _resetPlatformPathsCache,
153
143
  getAgentsConfigPath,
154
144
  getAgentsHome,
@@ -158,8 +148,6 @@ import {
158
148
  getAgentsMcpServersPath,
159
149
  getAgentsSpecDir,
160
150
  getAgentsWikiDir,
161
- getCanonicalSkillsDir,
162
- getCanonicalSkillsRoot,
163
151
  getLockFilePath,
164
152
  getPlatformLocations,
165
153
  getPlatformPaths,
@@ -167,11 +155,12 @@ import {
167
155
  getSystemInfo,
168
156
  resolveProviderSkillsDirs,
169
157
  resolveRegistryTemplatePath
170
- } from "./chunk-H5YXR2DC.js";
158
+ } from "./chunk-HDZYZTR2.js";
171
159
 
172
160
  // src/core/skills/integrity.ts
173
161
  import { existsSync, lstatSync, readlinkSync } from "fs";
174
162
  import { join, resolve } from "path";
163
+ import { resolveSkillsRoot } from "@cleocode/core/skills/skill-root.js";
175
164
  var CAAMP_SKILL_PREFIX = "ct-";
176
165
  function isCaampOwnedSkill(skillName) {
177
166
  return skillName.startsWith(CAAMP_SKILL_PREFIX);
@@ -181,7 +170,7 @@ async function checkSkillIntegrity(skillName, providers, scope = "global", proje
181
170
  const entry = lock.skills[skillName];
182
171
  const isCaampOwned = isCaampOwnedSkill(skillName);
183
172
  if (!entry) {
184
- const canonicalPath2 = join(getCanonicalSkillsDir(), skillName);
173
+ const canonicalPath2 = join(resolveSkillsRoot(), skillName);
185
174
  return {
186
175
  name: skillName,
187
176
  status: "not-tracked",
@@ -285,7 +274,7 @@ function shouldOverrideSkill(skillName, incomingSource, existingEntry) {
285
274
  return true;
286
275
  }
287
276
  async function validateInstructionIntegrity(providers, projectDir, scope, expectedContent) {
288
- const { checkAllInjections: checkAllInjections2 } = await import("./injector-QPOIJVOR.js");
277
+ const { checkAllInjections: checkAllInjections2 } = await import("./injector-3TOVIDBO.js");
289
278
  const results = await checkAllInjections2(providers, projectDir, scope, expectedContent);
290
279
  const issues = [];
291
280
  for (const result of results) {
@@ -312,7 +301,6 @@ async function validateInstructionIntegrity(providers, projectDir, scope, expect
312
301
  return issues;
313
302
  }
314
303
  export {
315
- AgentsSkillsRealDirError,
316
304
  CANONICAL_HOOK_EVENTS,
317
305
  DEFAULT_EXCLUSIVITY_MODE,
318
306
  EXCLUSIVITY_MODE_ENV_VAR,
@@ -321,15 +309,11 @@ export {
321
309
  PiHarness,
322
310
  PiRequiredError,
323
311
  RECOMMENDATION_ERROR_CODES,
324
- _resetLegacySkillsWarning,
325
312
  _resetPlatformPathsCache,
326
- applyDecision,
327
- buildBackupTimestamp,
328
313
  buildHookMatrix,
329
314
  buildInjectionContent,
330
315
  buildLibraryFromFiles,
331
316
  buildSkillsMap,
332
- caampStandaloneAdapters,
333
317
  catalog_exports as catalog,
334
318
  checkAllInjections,
335
319
  checkAllSkillIntegrity,
@@ -345,7 +329,6 @@ export {
345
329
  detectMcpInstallations,
346
330
  detectProjectProviders,
347
331
  detectProvider,
348
- discoverOrphans,
349
332
  discoverSkill,
350
333
  discoverSkills,
351
334
  ensureAllProviderInstructionFiles,
@@ -367,8 +350,6 @@ export {
367
350
  getAllProviders,
368
351
  getCanonicalEvent,
369
352
  getCanonicalEventsByCategory,
370
- getCanonicalSkillsDir,
371
- getCanonicalSkillsRoot,
372
353
  getCommonEvents,
373
354
  getCommonHookEvents,
374
355
  getEffectiveSkillsPaths,
@@ -438,7 +419,6 @@ export {
438
419
  recordSkillInstall,
439
420
  registerSkillLibrary,
440
421
  registerSkillLibraryFromPath,
441
- registerSkillsDoctorAdopt,
442
422
  removeConfig,
443
423
  removeInjection,
444
424
  removeMcpServer,
@@ -453,8 +433,6 @@ export {
453
433
  resolveNativeEvent,
454
434
  resolveProviderSkillsDirs,
455
435
  resolveRegistryTemplatePath,
456
- runDoctorAdopt,
457
- runDoctorBridge,
458
436
  scanDirectory,
459
437
  scanFile,
460
438
  scoreSkillRecommendation,
@@ -476,7 +454,6 @@ export {
476
454
  validateRecommendationCriteria,
477
455
  validateSkill,
478
456
  writeAgentFileToAllProviders,
479
- writeAuditLog,
480
457
  writeConfig
481
458
  };
482
459
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/skills/integrity.ts"],"sourcesContent":["/**\n * Skill integrity checking\n *\n * Validates that installed skills have intact symlinks, correct canonical paths,\n * and enforces ct-* prefix priority for CAAMP-shipped skills.\n */\n\nimport { existsSync, lstatSync, readlinkSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { LockEntry, Provider } from '../../types.js';\nimport { readLockFile } from '../lock-utils.js';\nimport { getCanonicalSkillsDir, resolveProviderSkillsDirs } from '../paths/standard.js';\n\n/** CAAMP-reserved skill prefix. Skills with this prefix are owned by CAAMP. */\nconst CAAMP_SKILL_PREFIX = 'ct-';\n\n/**\n * Status of a single skill's integrity check.\n *\n * @public\n */\nexport type SkillIntegrityStatus =\n | 'intact'\n | 'broken-symlink'\n | 'missing-canonical'\n | 'missing-link'\n | 'not-tracked'\n | 'tampered';\n\n/**\n * Result of checking a single skill's integrity.\n *\n * @public\n */\nexport interface SkillIntegrityResult {\n /** Skill name. */\n name: string;\n /** Overall integrity status. */\n status: SkillIntegrityStatus;\n /** Whether the canonical directory exists. */\n canonicalExists: boolean;\n /** Expected canonical path from lock file. */\n canonicalPath: string | null;\n /** Provider link statuses — which agents have valid symlinks. */\n linkStatuses: Array<{\n providerId: string;\n linkPath: string;\n exists: boolean;\n isSymlink: boolean;\n pointsToCanonical: boolean;\n }>;\n /** Whether this is a CAAMP-reserved (ct-*) skill. */\n isCaampOwned: boolean;\n /** Human-readable issue description, if any. */\n issue?: string;\n}\n\n/**\n * Check whether a skill name is reserved by CAAMP (ct-* prefix).\n *\n * @remarks\n * Skills with the `ct-` prefix are considered CAAMP-owned and receive\n * special treatment during installation conflict resolution.\n *\n * @param skillName - Skill name to check\n * @returns `true` if the skill name starts with `ct-`\n *\n * @example\n * ```typescript\n * isCaampOwnedSkill(\"ct-research-agent\"); // true\n * isCaampOwnedSkill(\"my-custom-skill\"); // false\n * ```\n *\n * @public\n */\nexport function isCaampOwnedSkill(skillName: string): boolean {\n return skillName.startsWith(CAAMP_SKILL_PREFIX);\n}\n\n/**\n * Check the integrity of a single installed skill.\n *\n * @remarks\n * Validates that the canonical directory exists on disk, the lock file entry\n * matches the actual state, and symlinks from provider skill directories\n * point to the canonical path.\n *\n * @param skillName - Name of the skill to check\n * @param providers - Providers to check symlinks for\n * @param scope - Whether to check global or project links\n * @param projectDir - Project directory (for project scope)\n * @returns Integrity check result\n *\n * @example\n * ```typescript\n * const result = await checkSkillIntegrity(\"ct-research-agent\", providers, \"global\");\n * if (result.status !== \"intact\") {\n * console.log(`Issue: ${result.issue}`);\n * }\n * ```\n *\n * @public\n */\nexport async function checkSkillIntegrity(\n skillName: string,\n providers: Provider[],\n scope: 'global' | 'project' = 'global',\n projectDir?: string,\n): Promise<SkillIntegrityResult> {\n const lock = await readLockFile();\n const entry = lock.skills[skillName];\n const isCaampOwned = isCaampOwnedSkill(skillName);\n\n // Not tracked in lock file\n if (!entry) {\n const canonicalPath = join(getCanonicalSkillsDir(), skillName);\n return {\n name: skillName,\n status: 'not-tracked',\n canonicalExists: existsSync(canonicalPath),\n canonicalPath: null,\n linkStatuses: [],\n isCaampOwned,\n issue: 'Skill is not tracked in the CAAMP lock file',\n };\n }\n\n const canonicalPath = entry.canonicalPath;\n const canonicalExists = existsSync(canonicalPath);\n\n // Check symlinks for each provider\n const linkStatuses: SkillIntegrityResult['linkStatuses'] = [];\n\n for (const provider of providers) {\n const targetDirs = resolveProviderSkillsDirs(provider, scope, projectDir);\n for (const skillsDir of targetDirs) {\n if (!skillsDir) continue;\n\n const linkPath = join(skillsDir, skillName);\n const exists = existsSync(linkPath);\n let isSymlink = false;\n let pointsToCanonical = false;\n\n if (exists) {\n try {\n const stat = lstatSync(linkPath);\n isSymlink = stat.isSymbolicLink();\n if (isSymlink) {\n const target = resolve(readlinkSync(linkPath));\n pointsToCanonical = target === resolve(canonicalPath);\n }\n } catch {\n // Can't stat — treat as broken\n }\n }\n\n linkStatuses.push({\n providerId: provider.id,\n linkPath,\n exists,\n isSymlink,\n pointsToCanonical,\n });\n }\n }\n\n // Determine overall status\n if (!canonicalExists) {\n return {\n name: skillName,\n status: 'missing-canonical',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `Canonical directory missing: ${canonicalPath}`,\n };\n }\n\n const brokenLinks = linkStatuses.filter((l) => !l.exists);\n const tamperedLinks = linkStatuses.filter((l) => l.exists && !l.pointsToCanonical);\n\n if (tamperedLinks.length > 0) {\n return {\n name: skillName,\n status: 'tampered',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `${tamperedLinks.length} link(s) do not point to canonical path`,\n };\n }\n\n if (brokenLinks.length > 0) {\n return {\n name: skillName,\n status: 'broken-symlink',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `${brokenLinks.length} symlink(s) missing`,\n };\n }\n\n return {\n name: skillName,\n status: 'intact',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n };\n}\n\n/**\n * Check integrity of all tracked skills.\n *\n * @remarks\n * Iterates over every skill in the lock file and runs\n * {@link checkSkillIntegrity} on each.\n *\n * @param providers - Providers to check symlinks for\n * @param scope - Whether to check global or project links\n * @param projectDir - Project directory (for project scope)\n * @returns Map of skill name to integrity result\n *\n * @example\n * ```typescript\n * const results = await checkAllSkillIntegrity(providers);\n * for (const [name, result] of results) {\n * console.log(`${name}: ${result.status}`);\n * }\n * ```\n *\n * @public\n */\nexport async function checkAllSkillIntegrity(\n providers: Provider[],\n scope: 'global' | 'project' = 'global',\n projectDir?: string,\n): Promise<Map<string, SkillIntegrityResult>> {\n const lock = await readLockFile();\n const results = new Map<string, SkillIntegrityResult>();\n\n for (const skillName of Object.keys(lock.skills)) {\n const result = await checkSkillIntegrity(skillName, providers, scope, projectDir);\n results.set(skillName, result);\n }\n\n return results;\n}\n\n/**\n * Resolve a skill name conflict where a user-installed skill collides\n * with a CAAMP-owned (ct-*) skill.\n *\n * @remarks\n * CAAMP-owned skills always win. Returns `true` if the incoming skill\n * should take precedence over the existing installation.\n *\n * @param skillName - Skill name to check\n * @param incomingSource - Source of the incoming skill installation\n * @param existingEntry - Existing lock entry, if any\n * @returns `true` if the incoming installation should proceed\n *\n * @example\n * ```typescript\n * const proceed = shouldOverrideSkill(\"ct-research-agent\", \"library\", existingEntry);\n * if (proceed) {\n * // Safe to install/override\n * }\n * ```\n *\n * @public\n */\nexport function shouldOverrideSkill(\n skillName: string,\n incomingSource: string,\n existingEntry: LockEntry | undefined,\n): boolean {\n // No existing entry — always allow\n if (!existingEntry) return true;\n\n // For ct-* skills, CAAMP package source always wins\n if (isCaampOwnedSkill(skillName)) {\n // If incoming is from CAAMP package (library source), it always wins\n if (existingEntry.sourceType === 'library') return true;\n // If existing is from CAAMP but incoming is user, CAAMP wins (block user)\n return true;\n }\n\n // Non-ct-* skills: user always wins\n return true;\n}\n\n/**\n * Validate instruction file injection status across all providers.\n *\n * @remarks\n * Checks that CAAMP blocks exist and are current in all relevant\n * instruction files (CLAUDE.md, AGENTS.md, GEMINI.md).\n *\n * @param providers - Providers to check\n * @param projectDir - Project directory\n * @param scope - Whether to check global or project files\n * @param expectedContent - Expected CAAMP block content\n * @returns Array of file paths with issues\n *\n * @example\n * ```typescript\n * const issues = await validateInstructionIntegrity(providers, process.cwd(), \"project\");\n * for (const issue of issues) {\n * console.log(`${issue.providerId}: ${issue.issue} (${issue.file})`);\n * }\n * ```\n *\n * @public\n */\nexport async function validateInstructionIntegrity(\n providers: Provider[],\n projectDir: string,\n scope: 'project' | 'global',\n expectedContent?: string,\n): Promise<Array<{ file: string; providerId: string; issue: string }>> {\n const { checkAllInjections } = await import('../instructions/injector.js');\n const results = await checkAllInjections(providers, projectDir, scope, expectedContent);\n const issues: Array<{ file: string; providerId: string; issue: string }> = [];\n\n for (const result of results) {\n if (result.status === 'missing') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'Instruction file does not exist',\n });\n } else if (result.status === 'none') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'No CAAMP injection block found',\n });\n } else if (result.status === 'outdated') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'CAAMP injection block is outdated',\n });\n }\n }\n\n return issues;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,YAAY,WAAW,oBAAoB;AACpD,SAAS,MAAM,eAAe;AAM9B,IAAM,qBAAqB;AA6DpB,SAAS,kBAAkB,WAA4B;AAC5D,SAAO,UAAU,WAAW,kBAAkB;AAChD;AA0BA,eAAsB,oBACpB,WACA,WACA,QAA8B,UAC9B,YAC+B;AAC/B,QAAM,OAAO,MAAM,aAAa;AAChC,QAAM,QAAQ,KAAK,OAAO,SAAS;AACnC,QAAM,eAAe,kBAAkB,SAAS;AAGhD,MAAI,CAAC,OAAO;AACV,UAAMA,iBAAgB,KAAK,sBAAsB,GAAG,SAAS;AAC7D,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,iBAAiB,WAAWA,cAAa;AAAA,MACzC,eAAe;AAAA,MACf,cAAc,CAAC;AAAA,MACf;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,MAA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,QACnB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["canonicalPath","checkAllInjections"]}
1
+ {"version":3,"sources":["../src/core/skills/integrity.ts"],"sourcesContent":["/**\n * Skill integrity checking\n *\n * Validates that installed skills have intact symlinks, correct canonical paths,\n * and enforces ct-* prefix priority for CAAMP-shipped skills.\n */\n\nimport { existsSync, lstatSync, readlinkSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { resolveSkillsRoot } from '@cleocode/core/skills/skill-root.js';\nimport type { LockEntry, Provider } from '../../types.js';\nimport { readLockFile } from '../lock-utils.js';\nimport { resolveProviderSkillsDirs } from '../paths/standard.js';\n\n/** CAAMP-reserved skill prefix. Skills with this prefix are owned by CAAMP. */\nconst CAAMP_SKILL_PREFIX = 'ct-';\n\n/**\n * Status of a single skill's integrity check.\n *\n * @public\n */\nexport type SkillIntegrityStatus =\n | 'intact'\n | 'broken-symlink'\n | 'missing-canonical'\n | 'missing-link'\n | 'not-tracked'\n | 'tampered';\n\n/**\n * Result of checking a single skill's integrity.\n *\n * @public\n */\nexport interface SkillIntegrityResult {\n /** Skill name. */\n name: string;\n /** Overall integrity status. */\n status: SkillIntegrityStatus;\n /** Whether the canonical directory exists. */\n canonicalExists: boolean;\n /** Expected canonical path from lock file. */\n canonicalPath: string | null;\n /** Provider link statuses — which agents have valid symlinks. */\n linkStatuses: Array<{\n providerId: string;\n linkPath: string;\n exists: boolean;\n isSymlink: boolean;\n pointsToCanonical: boolean;\n }>;\n /** Whether this is a CAAMP-reserved (ct-*) skill. */\n isCaampOwned: boolean;\n /** Human-readable issue description, if any. */\n issue?: string;\n}\n\n/**\n * Check whether a skill name is reserved by CAAMP (ct-* prefix).\n *\n * @remarks\n * Skills with the `ct-` prefix are considered CAAMP-owned and receive\n * special treatment during installation conflict resolution.\n *\n * @param skillName - Skill name to check\n * @returns `true` if the skill name starts with `ct-`\n *\n * @example\n * ```typescript\n * isCaampOwnedSkill(\"ct-research-agent\"); // true\n * isCaampOwnedSkill(\"my-custom-skill\"); // false\n * ```\n *\n * @public\n */\nexport function isCaampOwnedSkill(skillName: string): boolean {\n return skillName.startsWith(CAAMP_SKILL_PREFIX);\n}\n\n/**\n * Check the integrity of a single installed skill.\n *\n * @remarks\n * Validates that the canonical directory exists on disk, the lock file entry\n * matches the actual state, and symlinks from provider skill directories\n * point to the canonical path.\n *\n * @param skillName - Name of the skill to check\n * @param providers - Providers to check symlinks for\n * @param scope - Whether to check global or project links\n * @param projectDir - Project directory (for project scope)\n * @returns Integrity check result\n *\n * @example\n * ```typescript\n * const result = await checkSkillIntegrity(\"ct-research-agent\", providers, \"global\");\n * if (result.status !== \"intact\") {\n * console.log(`Issue: ${result.issue}`);\n * }\n * ```\n *\n * @public\n */\nexport async function checkSkillIntegrity(\n skillName: string,\n providers: Provider[],\n scope: 'global' | 'project' = 'global',\n projectDir?: string,\n): Promise<SkillIntegrityResult> {\n const lock = await readLockFile();\n const entry = lock.skills[skillName];\n const isCaampOwned = isCaampOwnedSkill(skillName);\n\n // Not tracked in lock file\n if (!entry) {\n const canonicalPath = join(resolveSkillsRoot(), skillName);\n return {\n name: skillName,\n status: 'not-tracked',\n canonicalExists: existsSync(canonicalPath),\n canonicalPath: null,\n linkStatuses: [],\n isCaampOwned,\n issue: 'Skill is not tracked in the CAAMP lock file',\n };\n }\n\n const canonicalPath = entry.canonicalPath;\n const canonicalExists = existsSync(canonicalPath);\n\n // Check symlinks for each provider\n const linkStatuses: SkillIntegrityResult['linkStatuses'] = [];\n\n for (const provider of providers) {\n const targetDirs = resolveProviderSkillsDirs(provider, scope, projectDir);\n for (const skillsDir of targetDirs) {\n if (!skillsDir) continue;\n\n const linkPath = join(skillsDir, skillName);\n const exists = existsSync(linkPath);\n let isSymlink = false;\n let pointsToCanonical = false;\n\n if (exists) {\n try {\n const stat = lstatSync(linkPath);\n isSymlink = stat.isSymbolicLink();\n if (isSymlink) {\n const target = resolve(readlinkSync(linkPath));\n pointsToCanonical = target === resolve(canonicalPath);\n }\n } catch {\n // Can't stat — treat as broken\n }\n }\n\n linkStatuses.push({\n providerId: provider.id,\n linkPath,\n exists,\n isSymlink,\n pointsToCanonical,\n });\n }\n }\n\n // Determine overall status\n if (!canonicalExists) {\n return {\n name: skillName,\n status: 'missing-canonical',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `Canonical directory missing: ${canonicalPath}`,\n };\n }\n\n const brokenLinks = linkStatuses.filter((l) => !l.exists);\n const tamperedLinks = linkStatuses.filter((l) => l.exists && !l.pointsToCanonical);\n\n if (tamperedLinks.length > 0) {\n return {\n name: skillName,\n status: 'tampered',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `${tamperedLinks.length} link(s) do not point to canonical path`,\n };\n }\n\n if (brokenLinks.length > 0) {\n return {\n name: skillName,\n status: 'broken-symlink',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n issue: `${brokenLinks.length} symlink(s) missing`,\n };\n }\n\n return {\n name: skillName,\n status: 'intact',\n canonicalExists,\n canonicalPath,\n linkStatuses,\n isCaampOwned,\n };\n}\n\n/**\n * Check integrity of all tracked skills.\n *\n * @remarks\n * Iterates over every skill in the lock file and runs\n * {@link checkSkillIntegrity} on each.\n *\n * @param providers - Providers to check symlinks for\n * @param scope - Whether to check global or project links\n * @param projectDir - Project directory (for project scope)\n * @returns Map of skill name to integrity result\n *\n * @example\n * ```typescript\n * const results = await checkAllSkillIntegrity(providers);\n * for (const [name, result] of results) {\n * console.log(`${name}: ${result.status}`);\n * }\n * ```\n *\n * @public\n */\nexport async function checkAllSkillIntegrity(\n providers: Provider[],\n scope: 'global' | 'project' = 'global',\n projectDir?: string,\n): Promise<Map<string, SkillIntegrityResult>> {\n const lock = await readLockFile();\n const results = new Map<string, SkillIntegrityResult>();\n\n for (const skillName of Object.keys(lock.skills)) {\n const result = await checkSkillIntegrity(skillName, providers, scope, projectDir);\n results.set(skillName, result);\n }\n\n return results;\n}\n\n/**\n * Resolve a skill name conflict where a user-installed skill collides\n * with a CAAMP-owned (ct-*) skill.\n *\n * @remarks\n * CAAMP-owned skills always win. Returns `true` if the incoming skill\n * should take precedence over the existing installation.\n *\n * @param skillName - Skill name to check\n * @param incomingSource - Source of the incoming skill installation\n * @param existingEntry - Existing lock entry, if any\n * @returns `true` if the incoming installation should proceed\n *\n * @example\n * ```typescript\n * const proceed = shouldOverrideSkill(\"ct-research-agent\", \"library\", existingEntry);\n * if (proceed) {\n * // Safe to install/override\n * }\n * ```\n *\n * @public\n */\nexport function shouldOverrideSkill(\n skillName: string,\n incomingSource: string,\n existingEntry: LockEntry | undefined,\n): boolean {\n // No existing entry — always allow\n if (!existingEntry) return true;\n\n // For ct-* skills, CAAMP package source always wins\n if (isCaampOwnedSkill(skillName)) {\n // If incoming is from CAAMP package (library source), it always wins\n if (existingEntry.sourceType === 'library') return true;\n // If existing is from CAAMP but incoming is user, CAAMP wins (block user)\n return true;\n }\n\n // Non-ct-* skills: user always wins\n return true;\n}\n\n/**\n * Validate instruction file injection status across all providers.\n *\n * @remarks\n * Checks that CAAMP blocks exist and are current in all relevant\n * instruction files (CLAUDE.md, AGENTS.md, GEMINI.md).\n *\n * @param providers - Providers to check\n * @param projectDir - Project directory\n * @param scope - Whether to check global or project files\n * @param expectedContent - Expected CAAMP block content\n * @returns Array of file paths with issues\n *\n * @example\n * ```typescript\n * const issues = await validateInstructionIntegrity(providers, process.cwd(), \"project\");\n * for (const issue of issues) {\n * console.log(`${issue.providerId}: ${issue.issue} (${issue.file})`);\n * }\n * ```\n *\n * @public\n */\nexport async function validateInstructionIntegrity(\n providers: Provider[],\n projectDir: string,\n scope: 'project' | 'global',\n expectedContent?: string,\n): Promise<Array<{ file: string; providerId: string; issue: string }>> {\n const { checkAllInjections } = await import('../instructions/injector.js');\n const results = await checkAllInjections(providers, projectDir, scope, expectedContent);\n const issues: Array<{ file: string; providerId: string; issue: string }> = [];\n\n for (const result of results) {\n if (result.status === 'missing') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'Instruction file does not exist',\n });\n } else if (result.status === 'none') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'No CAAMP injection block found',\n });\n } else if (result.status === 'outdated') {\n issues.push({\n file: result.file,\n providerId: result.provider,\n issue: 'CAAMP injection block is outdated',\n });\n }\n }\n\n return issues;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,YAAY,WAAW,oBAAoB;AACpD,SAAS,MAAM,eAAe;AAC9B,SAAS,yBAAyB;AAMlC,IAAM,qBAAqB;AA6DpB,SAAS,kBAAkB,WAA4B;AAC5D,SAAO,UAAU,WAAW,kBAAkB;AAChD;AA0BA,eAAsB,oBACpB,WACA,WACA,QAA8B,UAC9B,YAC+B;AAC/B,QAAM,OAAO,MAAM,aAAa;AAChC,QAAM,QAAQ,KAAK,OAAO,SAAS;AACnC,QAAM,eAAe,kBAAkB,SAAS;AAGhD,MAAI,CAAC,OAAO;AACV,UAAMA,iBAAgB,KAAK,kBAAkB,GAAG,SAAS;AACzD,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,iBAAiB,WAAWA,cAAa;AAAA,MACzC,eAAe;AAAA,MACf,cAAc,CAAC;AAAA,MACf;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,MAAM;AAC5B,QAAM,kBAAkB,WAAW,aAAa;AAGhD,QAAM,eAAqD,CAAC;AAE5D,aAAW,YAAY,WAAW;AAChC,UAAM,aAAa,0BAA0B,UAAU,OAAO,UAAU;AACxE,eAAW,aAAa,YAAY;AAClC,UAAI,CAAC,UAAW;AAEhB,YA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AACF;AAwBA,eAAsB,uBACpB,WACA,QAA8B,UAC9B,YAC4C;AAC5C,QAAM,OAAO,MAAM,aAAa;AAChC,QAAM,UAAU,oBAAI,IAAkC;AAEtD,aAAW,aAAa,OAAO,KAAK,KAAK,MAAM,GAAG;AAChD,UAAM,SAAS,MAAM,oBAAoB,WAAW,WAAW,OAAO,UAAU;AAChF,YAAQ,IAAI,WAAW,MAAM;AAAA,EAC/B;AAEA,SAAO;AACT;AAyBO,SAAS,oBACd,WACA,gBACA,eACS;AAET,MAAI,CAAC,cAAe,QAAO;AAG3B,MAAI,kBAAkB,SAAS,GAAG;AAEhC,QAAI,cAAc,eAAe,UAAW,QAAO;AAEnD,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAyBA,eAAsB,6BACpB,WACA,YACA,OACA,iBACqE;AACrE,QAAM,EAAE,oBAAAC,oBAAmB,IAAI,MAAM,OAAO,wBAA6B;AACzE,QAAM,UAAU,MAAMA,oBAAmB,WAAW,YAAY,OAAO,eAAe;AACtF,QAAM,SAAqE,CAAC;AAE5E,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,WAAW,WAAW;AAC/B,aAAO,KAAK;AAAA,QACV,MAAM,OAAO;AAAA,QACb,YAAY,OAAO;AAAA,QACnB,OAAO;AAAA,MACT,CAAC;AAAA,IACH,WAAW,OAAO,WAAW,QAAQ;AACnC,aAAO,KAAK;AAAA,QACV,MAAM,OAAO;AAAA,QACb,YAAY,OAAO;AAAA,QACnB,OAAO;AAAA,MACT,CAAC;AAAA,IACH,WAAW,OAAO,WAAW,YAAY;AACvC,aAAO,KAAK;AAAA,QACV,MAAM,OAAO;AAAA,QACb,YAAY,OAAO;AAAA,QACnB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["canonicalPath","checkAllInjections"]}
@@ -11,8 +11,8 @@ import {
11
11
  parseCaampBlocks,
12
12
  removeInjection,
13
13
  writeAgentFileToAllProviders
14
- } from "./chunk-PGETUTYZ.js";
15
- import "./chunk-H5YXR2DC.js";
14
+ } from "./chunk-EH5U4PRC.js";
15
+ import "./chunk-HDZYZTR2.js";
16
16
  export {
17
17
  checkAllInjections,
18
18
  checkInjection,
@@ -27,4 +27,4 @@ export {
27
27
  removeInjection,
28
28
  writeAgentFileToAllProviders
29
29
  };
30
- //# sourceMappingURL=injector-QPOIJVOR.js.map
30
+ //# sourceMappingURL=injector-3TOVIDBO.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/caamp",
3
- "version": "2026.5.87",
3
+ "version": "2026.5.89",
4
4
  "description": "Central AI Agent Managed Packages - unified provider registry and package manager for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,10 +50,11 @@
50
50
  "jsonc-parser": "^3.3.1",
51
51
  "picocolors": "^1.1.1",
52
52
  "simple-git": "3.33.0",
53
- "@cleocode/contracts": "2026.5.87",
54
- "@cleocode/paths": "2026.5.87",
55
- "@cleocode/cant": "2026.5.87",
56
- "@cleocode/lafs": "2026.5.87"
53
+ "@cleocode/cant": "2026.5.89",
54
+ "@cleocode/contracts": "2026.5.89",
55
+ "@cleocode/lafs": "2026.5.89",
56
+ "@cleocode/paths": "2026.5.89",
57
+ "@cleocode/core": "2026.5.89"
57
58
  },
58
59
  "devDependencies": {
59
60
  "@biomejs/biome": "2.4.11",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/platform-paths.ts","../src/core/paths/standard.ts"],"sourcesContent":["/**\n * CAAMP platform-path façade — bound to `(appName='agents', envVar='AGENTS_HOME')`.\n *\n * The shared platform-paths factory now lives in `@cleocode/paths` (the\n * XDG / env-paths SSoT for the CLEO ecosystem). This module re-exposes the\n * factory + types and pre-binds an `agents`-scoped resolver so existing CAAMP\n * consumers keep working unchanged.\n *\n * Platform path defaults (no `AGENTS_HOME` set):\n * data: ~/.local/share/agents | ~/Library/Application Support/agents | %LOCALAPPDATA%\\agents\\Data\n * config: ~/.config/agents | ~/Library/Preferences/agents | %APPDATA%\\agents\\Config\n * cache: ~/.cache/agents | ~/Library/Caches/agents | %LOCALAPPDATA%\\agents\\Cache\n * log: ~/.local/state/agents | ~/Library/Logs/agents | %LOCALAPPDATA%\\agents\\Log\n * temp: /tmp/<user>/agents | /var/folders/.../agents | %TEMP%\\agents\n *\n * `AGENTS_HOME` env var overrides the data path (with tilde expansion).\n *\n * @task T1887\n */\n\nimport {\n createPlatformPathsResolver,\n type PlatformPaths,\n type PlatformPathsResolver,\n type SystemInfo,\n} from '@cleocode/paths';\n\nexport type { PlatformPaths, PlatformPathsResolver, SystemInfo };\nexport { createPlatformPathsResolver };\n\nconst agentsResolver = createPlatformPathsResolver('agents', 'AGENTS_HOME');\n\n/**\n * Get OS-appropriate paths for CAAMP's global directories.\n *\n * Reads fresh on every call (env-paths is microsecond-fast). The\n * `AGENTS_HOME` env var overrides the data path with tilde expansion.\n *\n * @public\n */\nexport function getPlatformPaths(): PlatformPaths {\n return agentsResolver.getPlatformPaths();\n}\n\n/**\n * Get a cached system information snapshot.\n *\n * Captured once and reused for the process lifetime. Includes platform,\n * architecture, hostname, Node version, and resolved paths.\n *\n * @public\n */\nexport function getSystemInfo(): SystemInfo {\n return agentsResolver.getSystemInfo();\n}\n\n/**\n * Invalidate the cached system info snapshot. Use in tests after\n * mutating `AGENTS_HOME`.\n *\n * @internal\n */\nexport function _resetPlatformPathsCache(): void {\n agentsResolver.resetCache();\n}\n","import { existsSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { getCleoHome } from '@cleocode/paths';\nimport type { Provider } from '../../types.js';\nimport { getPlatformPaths } from '../platform-paths.js';\n\n/**\n * Scope for path resolution, either global (user home) or project-local.\n *\n * @remarks\n * Global scope resolves paths under the user's home directory (e.g., `~/.agents/`).\n * Project scope resolves paths relative to the project root (e.g., `<project>/.agents/`).\n *\n * @public\n */\nexport type PathScope = 'project' | 'global';\n\n/**\n * Platform-specific directory locations for agent configuration.\n *\n * @remarks\n * Provides resolved paths for the current operating system, accounting for\n * platform differences in config directory locations (XDG on Linux, Library on macOS,\n * AppData on Windows).\n *\n * @public\n */\nexport interface PlatformLocations {\n /** The user's home directory path. */\n home: string;\n /** The platform-specific configuration directory. */\n config: string;\n /** The VS Code user settings directory. */\n vscodeConfig: string;\n /** The Zed editor configuration directory. */\n zedConfig: string;\n /** The Claude Desktop application configuration directory. */\n claudeDesktopConfig: string;\n /** List of application directories (macOS only). */\n applications: string[];\n}\n\n/**\n * Resolves platform-specific directory locations for the current OS.\n *\n * @remarks\n * Detects the current platform and returns appropriate paths for configuration,\n * editor settings, and application directories. Uses `XDG_CONFIG_HOME` on Linux\n * and macOS when available, falls back to conventional defaults. On Windows,\n * uses `APPDATA` or defaults to `~/AppData/Roaming`.\n *\n * @returns Platform-specific directory locations\n *\n * @example\n * ```typescript\n * const locations = getPlatformLocations();\n * console.log(locations.config); // e.g., \"/home/user/.config\"\n * ```\n *\n * @public\n */\nexport function getPlatformLocations(): PlatformLocations {\n const home = homedir();\n const platform = process.platform;\n\n if (platform === 'win32') {\n const appData = process.env['APPDATA'] ?? join(home, 'AppData', 'Roaming');\n return {\n home,\n config: appData,\n vscodeConfig: join(appData, 'Code', 'User'),\n zedConfig: join(appData, 'Zed'),\n claudeDesktopConfig: join(appData, 'Claude'),\n applications: [],\n };\n }\n\n if (platform === 'darwin') {\n const config = process.env['XDG_CONFIG_HOME'] ?? join(home, '.config');\n return {\n home,\n config,\n vscodeConfig: join(home, 'Library', 'Application Support', 'Code', 'User'),\n zedConfig: join(home, 'Library', 'Application Support', 'Zed'),\n claudeDesktopConfig: join(home, 'Library', 'Application Support', 'Claude'),\n applications: ['/Applications', join(home, 'Applications')],\n };\n }\n\n const config = process.env['XDG_CONFIG_HOME'] ?? join(home, '.config');\n return {\n home,\n config,\n vscodeConfig: join(config, 'Code', 'User'),\n zedConfig: join(config, 'zed'),\n claudeDesktopConfig: join(config, 'Claude'),\n applications: [],\n };\n}\n\n/**\n * Returns the global agents home directory path.\n *\n * @remarks\n * Delegates to the platform paths module to resolve the data directory\n * for the current operating system. This is the root for global agent\n * configuration such as canonical skills and lock files.\n *\n * @returns The absolute path to the global agents home directory\n *\n * @example\n * ```typescript\n * const home = getAgentsHome();\n * // e.g., \"/home/user/.local/share/caamp\"\n * ```\n *\n * @public\n */\nexport function getAgentsHome(): string {\n return getPlatformPaths().data;\n}\n\n/**\n * Returns the project-local `.agents` directory path.\n *\n * @remarks\n * Joins the project root with `.agents` to produce the conventional\n * project-scoped agent configuration directory.\n *\n * @param projectRoot - The project root directory, defaults to `process.cwd()`\n * @returns The absolute path to the project's `.agents` directory\n *\n * @example\n * ```typescript\n * const dir = getProjectAgentsDir(\"/home/user/my-project\");\n * // returns \"/home/user/my-project/.agents\"\n * ```\n *\n * @public\n */\nexport function getProjectAgentsDir(projectRoot = process.cwd()): string {\n return join(projectRoot, '.agents');\n}\n\n/**\n * Resolves a relative path against a project directory.\n *\n * @remarks\n * A simple path join utility that combines the project directory with\n * the given relative path to produce an absolute path.\n *\n * @param relativePath - The relative path to resolve\n * @param projectDir - The project root directory, defaults to `process.cwd()`\n * @returns The resolved absolute path\n *\n * @example\n * ```typescript\n * const path = resolveProjectPath(\".agents/config.toml\", \"/home/user/project\");\n * // returns \"/home/user/project/.agents/config.toml\"\n * ```\n *\n * @public\n */\nexport function resolveProjectPath(relativePath: string, projectDir = process.cwd()): string {\n return join(projectDir, relativePath);\n}\n\n/**\n * Subpath for the new SSoT skills directory under the user's home.\n *\n * @remarks\n * Architecture-v3 §1 locks the user-machine install root for ALL skills\n * (Sphere A canonical AND Sphere B user/community/agent-created) to\n * `~/.cleo/skills/`. This constant centralises that subpath so the\n * fallback-resolver and the migration helpers share one source of truth.\n *\n * @internal\n */\nconst NEW_SSOT_SKILLS_SUBPATH = join('.cleo', 'skills');\n\n/**\n * One-shot deprecation-warning flag for the legacy XDG skills path.\n *\n * @remarks\n * When the new SSoT path under `~/.cleo/skills/` is missing but the legacy\n * `~/.local/share/agents/skills/` directory exists, the resolver returns the\n * legacy path AND emits a one-shot stderr warning so the user knows to run\n * `cleo skills doctor migrate`. The flag is reset by\n * {@link _resetLegacySkillsWarning} so tests can assert emission.\n */\nlet legacySkillsWarningEmitted = false;\n\n/**\n * Reset the cached deprecation-warning flag.\n *\n * @remarks\n * Test-only seam. Production code should never call this.\n *\n * @internal\n */\nexport function _resetLegacySkillsWarning(): void {\n legacySkillsWarningEmitted = false;\n}\n\n/**\n * Returns the canonical user-machine skills install root.\n *\n * @remarks\n * Per architecture-v3 §1 the new SSoT for ALL installed skills is\n * `~/.cleo/skills/` (replacing the legacy XDG path\n * `~/.local/share/agents/skills/`). This resolver implements the migration\n * contract: it ALWAYS returns the new SSoT when it exists, falls through to\n * the legacy path as a read-only fallback for one release cycle, and\n * defaults to the new SSoT on a fresh install so first-write lands in the\n * correct location.\n *\n * Resolution order:\n *\n * 1. `~/.cleo/skills/` (new SSoT — preferred). Returned when it exists.\n * 2. `getAgentsHome()/skills` (legacy XDG via `AGENTS_HOME` /\n * `~/.local/share/agents/skills/`). Returned when the new SSoT is missing\n * but the legacy directory exists. Emits a one-shot stderr deprecation\n * warning so the user is prompted to migrate.\n * 3. `~/.cleo/skills/` (new SSoT) on a fresh install when neither exists,\n * so first-write creates the correct directory.\n *\n * **Test override:** when the `AGENTS_HOME` env var is set explicitly (the\n * primary test seam used by `skills-installer.test.ts`), the resolver SKIPS\n * step 1 and returns `getAgentsHome()/skills` directly. This preserves the\n * existing test surface (tmpdirs via `AGENTS_HOME`) while production paths\n * resolve through the new SSoT chain.\n *\n * @returns Absolute path to the resolved canonical skills directory\n *\n * @example\n * ```typescript\n * const dir = getCanonicalSkillsRoot();\n * // Fresh install: \"/home/user/.cleo/skills\"\n * // Legacy install + warning: \"/home/user/.local/share/agents/skills\"\n * // Test (AGENTS_HOME=/tmp/foo): \"/tmp/foo/skills\"\n * ```\n *\n * @task T9659\n * @public\n */\nexport function getCanonicalSkillsRoot(): string {\n // Test override: explicit AGENTS_HOME wins outright so unit tests with\n // tmpdir-backed canonical roots keep working without further wiring.\n if (process.env['AGENTS_HOME']) {\n return join(getAgentsHome(), 'skills');\n }\n\n const home = homedir();\n const newPath = join(home, NEW_SSOT_SKILLS_SUBPATH);\n if (existsSync(newPath)) {\n return newPath;\n }\n\n const legacyPath = join(getAgentsHome(), 'skills');\n if (existsSync(legacyPath)) {\n if (!legacySkillsWarningEmitted) {\n legacySkillsWarningEmitted = true;\n process.stderr.write(\n `[caamp] WARNING: skills root resolved from legacy path ${legacyPath}. ` +\n 'Run `cleo skills doctor migrate` to move to ~/.cleo/skills/.\\n',\n );\n }\n return legacyPath;\n }\n\n // Fresh install — write to the new SSoT so first install lands canonically.\n return newPath;\n}\n\n/**\n * Returns the canonical skills storage directory path.\n *\n * @remarks\n * Skills are stored once in this canonical directory and symlinked into\n * provider-specific locations. This is the single source of truth for\n * installed skill files. **T9659 — this now delegates to\n * {@link getCanonicalSkillsRoot} so the SSoT is `~/.cleo/skills/` with the\n * legacy XDG path as a read-only fallback per architecture-v3 §1.**\n *\n * @returns The absolute path to the canonical skills directory\n *\n * @example\n * ```typescript\n * const dir = getCanonicalSkillsDir();\n * // e.g., \"/home/user/.cleo/skills\" (new SSoT)\n * ```\n *\n * @public\n */\nexport function getCanonicalSkillsDir(): string {\n return getCanonicalSkillsRoot();\n}\n\n/**\n * Returns the path to the CAAMP lock file.\n *\n * @remarks\n * The lock file tracks installed skills and their versions to enable\n * deterministic reinstallation and conflict detection.\n *\n * @returns The absolute path to the `.caamp-lock.json` file\n *\n * @example\n * ```typescript\n * const lockPath = getLockFilePath();\n * // e.g., \"/home/user/.local/share/caamp/.caamp-lock.json\"\n * ```\n *\n * @public\n */\nexport function getLockFilePath(): string {\n return join(getAgentsHome(), '.caamp-lock.json');\n}\n\n// ── .agents/ Standard Directory Structure ────────────────────────────\n\n/**\n * Gets the MCP directory within the `.agents/` standard structure.\n *\n * @remarks\n * Resolves the MCP configuration directory based on scope. Global scope\n * points to `~/.agents/mcp/`, while project scope points to\n * `<project>/.agents/mcp/`.\n *\n * @param scope - `\"global\"` for `~/.agents/mcp/`, `\"project\"` for `<project>/.agents/mcp/`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the MCP directory\n *\n * @example\n * ```typescript\n * const globalMcp = getAgentsMcpDir(\"global\");\n * const projectMcp = getAgentsMcpDir(\"project\", \"/home/user/project\");\n * ```\n *\n * @public\n */\nexport function getAgentsMcpDir(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'mcp');\n return join(projectDir ?? process.cwd(), '.agents', 'mcp');\n}\n\n/**\n * Gets the MCP servers.json path within the `.agents/` standard structure.\n *\n * @remarks\n * Per the `.agents/` standard (Section 9), this is the canonical MCP\n * server registry that should be checked before legacy per-provider configs.\n *\n * @param scope - `\"global\"` for `~/.agents/mcp/servers.json`, `\"project\"` for `<project>/.agents/mcp/servers.json`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the `servers.json` file\n *\n * @example\n * ```typescript\n * const serversPath = getAgentsMcpServersPath(\"global\");\n * // e.g., \"/home/user/.agents/mcp/servers.json\"\n * ```\n *\n * @public\n */\nexport function getAgentsMcpServersPath(scope: PathScope = 'global', projectDir?: string): string {\n return join(getAgentsMcpDir(scope, projectDir), 'servers.json');\n}\n\n/**\n * Gets the primary AGENTS.md instruction file path within `.agents/`.\n *\n * @remarks\n * Returns the path to the AGENTS.md file for the given scope. This is the\n * standard instruction file that agents read for project or global guidance.\n *\n * @param scope - `\"global\"` for `~/.agents/AGENTS.md`, `\"project\"` for `<project>/.agents/AGENTS.md`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the AGENTS.md file\n *\n * @example\n * ```typescript\n * const agentsFile = getAgentsInstructFile(\"project\", \"/home/user/project\");\n * // returns \"/home/user/project/.agents/AGENTS.md\"\n * ```\n *\n * @public\n */\nexport function getAgentsInstructFile(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'AGENTS.md');\n return join(projectDir ?? process.cwd(), '.agents', 'AGENTS.md');\n}\n\n/**\n * Gets the config.toml path within the `.agents/` standard structure.\n *\n * @remarks\n * Returns the path to the TOML configuration file for agent settings.\n * Global scope points to `~/.agents/config.toml`, project scope points\n * to `<project>/.agents/config.toml`.\n *\n * @param scope - `\"global\"` for `~/.agents/config.toml`, `\"project\"` for `<project>/.agents/config.toml`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the config.toml file\n *\n * @example\n * ```typescript\n * const configPath = getAgentsConfigPath(\"global\");\n * // e.g., \"/home/user/.agents/config.toml\"\n * ```\n *\n * @public\n */\nexport function getAgentsConfigPath(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'config.toml');\n return join(projectDir ?? process.cwd(), '.agents', 'config.toml');\n}\n\n/**\n * Gets the wiki directory within the `.agents/` standard structure.\n *\n * @remarks\n * The wiki directory stores markdown documentation files that agents\n * can reference for project or global knowledge.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the wiki directory\n *\n * @example\n * ```typescript\n * const wikiDir = getAgentsWikiDir(\"project\", \"/home/user/project\");\n * // returns \"/home/user/project/.agents/wiki\"\n * ```\n *\n * @public\n */\nexport function getAgentsWikiDir(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'wiki');\n return join(projectDir ?? process.cwd(), '.agents', 'wiki');\n}\n\n/**\n * Gets the spec directory within the `.agents/` standard structure.\n *\n * @remarks\n * The spec directory stores specification files used by agents for\n * project architecture and design reference.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the spec directory\n *\n * @example\n * ```typescript\n * const specDir = getAgentsSpecDir(\"global\");\n * // e.g., \"/home/user/.agents/spec\"\n * ```\n *\n * @public\n */\nexport function getAgentsSpecDir(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'spec');\n return join(projectDir ?? process.cwd(), '.agents', 'spec');\n}\n\n/**\n * Gets the links directory within the `.agents/` standard structure.\n *\n * @remarks\n * The links directory stores symlinks or references to external resources\n * that agents can follow for additional context.\n *\n * @param scope - `\"global\"` or `\"project\"`\n * @param projectDir - Project root (defaults to `process.cwd()`)\n * @returns The absolute path to the links directory\n *\n * @example\n * ```typescript\n * const linksDir = getAgentsLinksDir(\"project\", \"/home/user/project\");\n * // returns \"/home/user/project/.agents/links\"\n * ```\n *\n * @public\n */\nexport function getAgentsLinksDir(scope: PathScope = 'global', projectDir?: string): string {\n if (scope === 'global') return join(getAgentsHome(), 'links');\n return join(projectDir ?? process.cwd(), '.agents', 'links');\n}\n\n/**\n * Resolve the CLEO home directory for template path expansion.\n *\n * @remarks\n * Delegates to {@link getCleoHome} from `@cleocode/paths`, which is the\n * canonical SSoT for XDG / platform-specific CLEO home resolution.\n *\n * @internal\n */\nfunction getCleoHomeForTemplate(): string {\n return getCleoHome();\n}\n\n/**\n * Resolves a registry template path by substituting platform variables.\n *\n * @remarks\n * Replaces template variables like `$HOME`, `$CONFIG`, `$VSCODE_CONFIG`,\n * `$ZED_CONFIG`, `$CLAUDE_DESKTOP_CONFIG`, `$AGENTS_HOME`, and `$CLEO_HOME`\n * with their actual platform-specific values. Used to resolve paths from\n * the provider registry JSON.\n *\n * @param template - The template string containing `$VARIABLE` placeholders\n * @returns The resolved absolute path with all variables expanded\n *\n * @example\n * ```typescript\n * const path = resolveRegistryTemplatePath(\"$HOME/.config/claude/settings.json\");\n * // e.g., \"/home/user/.config/claude/settings.json\"\n * ```\n *\n * @public\n */\nexport function resolveRegistryTemplatePath(template: string): string {\n const locations = getPlatformLocations();\n return template\n .replace(/\\$HOME/g, locations.home)\n .replace(/\\$CONFIG/g, locations.config)\n .replace(/\\$VSCODE_CONFIG/g, locations.vscodeConfig)\n .replace(/\\$ZED_CONFIG/g, locations.zedConfig)\n .replace(/\\$CLAUDE_DESKTOP_CONFIG/g, locations.claudeDesktopConfig)\n .replace(/\\$AGENTS_HOME/g, getAgentsHome())\n .replace(/\\$CLEO_HOME/g, getCleoHomeForTemplate());\n}\n\n/**\n * Resolves the configuration file path for a provider at the given scope.\n *\n * @remarks\n * For global scope, returns the provider's `configPathGlobal` directly.\n * For project scope, joins the project directory with the provider's\n * `configPathProject`. Returns null if the provider has no project-scoped\n * config path defined.\n *\n * @param provider - The provider whose config path to resolve\n * @param scope - Whether to resolve global or project config path\n * @param projectDir - The project root directory, defaults to `process.cwd()`\n * @returns The resolved config file path, or null if unavailable for the given scope\n *\n * @example\n * ```typescript\n * const configPath = resolveProviderConfigPath(provider, \"project\", \"/home/user/project\");\n * if (configPath) {\n * console.log(\"Config at:\", configPath);\n * }\n * ```\n *\n * @public\n */\nexport function resolveProviderConfigPath(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string | null {\n const mcp = provider.capabilities.mcp;\n if (!mcp) {\n return null;\n }\n if (scope === 'global') {\n return mcp.configPathGlobal;\n }\n if (!mcp.configPathProject) {\n return null;\n }\n return resolveProjectPath(mcp.configPathProject, projectDir);\n}\n\n/**\n * Determines the preferred configuration scope for a provider.\n *\n * @remarks\n * If the global flag is explicitly set, always returns `\"global\"`. Otherwise,\n * returns `\"project\"` if the provider supports project-scoped configuration,\n * or `\"global\"` as a fallback.\n *\n * @param provider - The provider to determine scope for\n * @param useGlobalFlag - Optional flag to force global scope\n * @returns The preferred path scope for configuration\n *\n * @example\n * ```typescript\n * const scope = resolvePreferredConfigScope(provider, false);\n * // returns \"project\" if provider has configPathProject, otherwise \"global\"\n * ```\n *\n * @public\n */\nexport function resolvePreferredConfigScope(\n provider: Provider,\n useGlobalFlag?: boolean,\n): PathScope {\n if (useGlobalFlag) {\n return 'global';\n }\n return provider.capabilities.mcp?.configPathProject ? 'project' : 'global';\n}\n\n/**\n * Resolves the skills directory path for a provider at the given scope.\n *\n * @remarks\n * For global scope, returns the provider's `pathSkills` directly.\n * For project scope, joins the project directory with the provider's\n * `pathProjectSkills` relative path.\n *\n * @param provider - The provider whose skills directory to resolve\n * @param scope - Whether to resolve global or project skills path\n * @param projectDir - The project root directory, defaults to `process.cwd()`\n * @returns The resolved skills directory path\n *\n * @example\n * ```typescript\n * const skillsDir = resolveProviderSkillsDir(provider, \"global\");\n * // e.g., \"/home/user/.claude/skills\"\n * ```\n *\n * @public\n */\nexport function resolveProviderSkillsDir(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string {\n if (scope === 'global') {\n return provider.pathSkills;\n }\n return resolveProjectPath(provider.pathProjectSkills, projectDir);\n}\n\n/**\n * Gets all target directories for skill installation based on provider precedence.\n *\n * @remarks\n * Resolves one or more skill directories based on the provider's skills\n * precedence setting. The precedence determines whether vendor-only, agents-canonical,\n * agents-first, agents-supported, or vendor-global-agents-project strategies are used.\n * Falls back to the vendor path when the agents path is not configured.\n *\n * @param provider - Provider to resolve paths for\n * @param scope - Whether to resolve global or project paths\n * @param projectDir - Project directory for project-scope resolution\n * @returns Array of target directories for symlink creation\n *\n * @example\n * ```typescript\n * const dirs = resolveProviderSkillsDirs(provider, \"project\", \"/home/user/project\");\n * for (const dir of dirs) {\n * console.log(\"Install skill to:\", dir);\n * }\n * ```\n *\n * @public\n */\nexport function resolveProviderSkillsDirs(\n provider: Provider,\n scope: PathScope,\n projectDir = process.cwd(),\n): string[] {\n const vendorPath = resolveProviderSkillsDir(provider, scope, projectDir);\n const precedence = provider.capabilities?.skills?.precedence ?? 'vendor-only';\n\n const resolveAgentsPath = (): string | null => {\n if (scope === 'global') {\n return provider.capabilities?.skills?.agentsGlobalPath ?? null;\n }\n const projectRelative = provider.capabilities?.skills?.agentsProjectPath ?? null;\n return projectRelative ? join(projectDir, projectRelative) : null;\n };\n\n switch (precedence) {\n case 'vendor-only':\n return [vendorPath];\n\n case 'agents-canonical': {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath] : [vendorPath];\n }\n\n case 'agents-first': {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath, vendorPath] : [vendorPath];\n }\n\n case 'agents-supported': {\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [vendorPath, agentsPath] : [vendorPath];\n }\n\n case 'vendor-global-agents-project': {\n if (scope === 'global') {\n return [vendorPath];\n }\n const agentsPath = resolveAgentsPath();\n return agentsPath ? [agentsPath, vendorPath] : [vendorPath];\n }\n\n default:\n return [vendorPath];\n }\n}\n\n/**\n * Resolves a provider's project-level path against a project directory.\n *\n * @remarks\n * Joins the project directory with the provider's `pathProject` relative path\n * to produce an absolute path for project-scoped provider configuration.\n *\n * @param provider - The provider whose project path to resolve\n * @param projectDir - The project root directory, defaults to `process.cwd()`\n * @returns The resolved absolute path for the provider's project directory\n *\n * @example\n * ```typescript\n * const projectPath = resolveProviderProjectPath(provider, \"/home/user/project\");\n * // e.g., \"/home/user/project/.claude\"\n * ```\n *\n * @public\n */\nexport function resolveProviderProjectPath(provider: Provider, projectDir = process.cwd()): string {\n return resolveProjectPath(provider.pathProject, projectDir);\n}\n\n/**\n * Locates the providers registry.json file by searching up from a start directory.\n *\n * @remarks\n * First checks common relative locations (3 levels up and 1 level up),\n * then walks up to 8 parent directories looking for `providers/registry.json`.\n * Throws if the registry file cannot be found.\n *\n * @param startDir - The directory to start searching from\n * @returns The absolute path to the found `providers/registry.json` file\n * @throws Error if `providers/registry.json` cannot be found within 8 parent levels\n *\n * @example\n * ```typescript\n * const registryPath = resolveProvidersRegistryPath(__dirname);\n * // e.g., \"/home/user/caamp/providers/registry.json\"\n * ```\n *\n * @public\n */\nexport function resolveProvidersRegistryPath(startDir: string): string {\n const candidates = [\n join(startDir, '..', '..', '..', 'providers', 'registry.json'),\n join(startDir, '..', 'providers', 'registry.json'),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n let current = startDir;\n for (let i = 0; i < 8; i += 1) {\n const candidate = join(current, 'providers', 'registry.json');\n if (existsSync(candidate)) {\n return candidate;\n }\n current = dirname(current);\n }\n\n throw new Error(`Cannot find providers/registry.json (searched from ${startDir})`);\n}\n\n/**\n * Normalizes a skill sub-path by cleaning separators and removing SKILL.md suffix.\n *\n * @remarks\n * Converts backslashes to forward slashes, strips leading slashes and\n * trailing `/SKILL.md`, and trims whitespace. Returns undefined for\n * empty or falsy inputs.\n *\n * @param path - The raw skill sub-path to normalize\n * @returns The normalized path, or undefined if the input is empty or falsy\n *\n * @example\n * ```typescript\n * const normalized = normalizeSkillSubPath(\"skills/my-skill/SKILL.md\");\n * // returns \"skills/my-skill\"\n * ```\n *\n * @public\n */\nexport function normalizeSkillSubPath(path: string | undefined): string | undefined {\n if (!path) return undefined;\n const normalized = path\n .replace(/\\\\/g, '/')\n .replace(/^\\/+/, '')\n .replace(/\\/SKILL\\.md$/i, '')\n .trim();\n return normalized.length > 0 ? normalized : undefined;\n}\n\n/**\n * Builds a list of candidate sub-paths for skill file resolution.\n *\n * @remarks\n * Normalizes both the marketplace and parsed paths, then generates additional\n * candidates by prepending known prefixes (`.agents`, `.claude`) to paths\n * starting with `skills/`. Returns a deduplicated list of candidates, with\n * an undefined entry as fallback if no candidates are found.\n *\n * @param marketplacePath - The sub-path from the marketplace listing\n * @param parsedPath - The sub-path parsed from the source URL\n * @returns A deduplicated array of candidate sub-paths\n *\n * @example\n * ```typescript\n * const candidates = buildSkillSubPathCandidates(\"skills/my-skill\", undefined);\n * // returns [\"skills/my-skill\", \".agents/skills/my-skill\", \".claude/skills/my-skill\"]\n * ```\n *\n * @public\n */\nexport function buildSkillSubPathCandidates(\n marketplacePath: string | undefined,\n parsedPath: string | undefined,\n): (string | undefined)[] {\n const candidates: (string | undefined)[] = [];\n const base = normalizeSkillSubPath(marketplacePath);\n const parsed = normalizeSkillSubPath(parsedPath);\n\n if (base) candidates.push(base);\n if (parsed) candidates.push(parsed);\n\n const knownPrefixes = ['.agents', '.claude'];\n for (const value of [base, parsed]) {\n if (!value?.startsWith('skills/')) continue;\n for (const prefix of knownPrefixes) {\n candidates.push(`${prefix}/${value}`);\n }\n }\n\n if (candidates.length === 0) {\n candidates.push(undefined);\n }\n\n return Array.from(new Set(candidates));\n}\n"],"mappings":";;;;;;;AAoBA;AAAA,EACE;AAAA,OAIK;AAKP,IAAM,iBAAiB,4BAA4B,UAAU,aAAa;AAUnE,SAAS,mBAAkC;AAChD,SAAO,eAAe,iBAAiB;AACzC;AAUO,SAAS,gBAA4B;AAC1C,SAAO,eAAe,cAAc;AACtC;AAQO,SAAS,2BAAiC;AAC/C,iBAAe,WAAW;AAC5B;;;AChEA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,SAAS,mBAAmB;AA2DrB,SAAS,uBAA0C;AACxD,QAAM,OAAO,QAAQ;AACrB,QAAM,WAAW,QAAQ;AAEzB,MAAI,aAAa,SAAS;AACxB,UAAM,UAAU,QAAQ,IAAI,SAAS,KAAK,KAAK,MAAM,WAAW,SAAS;AACzE,WAAO;AAAA,MACL;AAAA,MACA,QAAQ;AAAA,MACR,cAAc,KAAK,SAAS,QAAQ,MAAM;AAAA,MAC1C,WAAW,KAAK,SAAS,KAAK;AAAA,MAC9B,qBAAqB,KAAK,SAAS,QAAQ;AAAA,MAC3C,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AAEA,MAAI,aAAa,UAAU;AACzB,UAAMA,UAAS,QAAQ,IAAI,iBAAiB,KAAK,KAAK,MAAM,SAAS;AACrE,WAAO;AAAA,MACL;AAAA,MACA,QAAAA;AAAA,MACA,cAAc,KAAK,MAAM,WAAW,uBAAuB,QAAQ,MAAM;AAAA,MACzE,WAAW,KAAK,MAAM,WAAW,uBAAuB,KAAK;AAAA,MAC7D,qBAAqB,KAAK,MAAM,WAAW,uBAAuB,QAAQ;AAAA,MAC1E,cAAc,CAAC,iBAAiB,KAAK,MAAM,cAAc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