@cleocode/caamp 2026.5.88 → 2026.5.90

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.
@@ -2,7 +2,7 @@ import {
2
2
  resolveProviderSkillsDir,
3
3
  resolveProvidersRegistryPath,
4
4
  resolveRegistryTemplatePath
5
- } from "./chunk-H5YXR2DC.js";
5
+ } from "./chunk-HDZYZTR2.js";
6
6
 
7
7
  // src/core/instructions/injector.ts
8
8
  import { existsSync } from "fs";
@@ -647,4 +647,4 @@ export {
647
647
  getProviderAgentFolder,
648
648
  writeAgentFileToAllProviders
649
649
  };
650
- //# sourceMappingURL=chunk-PGETUTYZ.js.map
650
+ //# sourceMappingURL=chunk-EH5U4PRC.js.map
@@ -68,36 +68,6 @@ function getProjectAgentsDir(projectRoot = process.cwd()) {
68
68
  function resolveProjectPath(relativePath, projectDir = process.cwd()) {
69
69
  return join(projectDir, relativePath);
70
70
  }
71
- var NEW_SSOT_SKILLS_SUBPATH = join(".cleo", "skills");
72
- var legacySkillsWarningEmitted = false;
73
- function _resetLegacySkillsWarning() {
74
- legacySkillsWarningEmitted = false;
75
- }
76
- function getCanonicalSkillsRoot() {
77
- if (process.env["AGENTS_HOME"]) {
78
- return join(getAgentsHome(), "skills");
79
- }
80
- const home = homedir();
81
- const newPath = join(home, NEW_SSOT_SKILLS_SUBPATH);
82
- if (existsSync(newPath)) {
83
- return newPath;
84
- }
85
- const legacyPath = join(getAgentsHome(), "skills");
86
- if (existsSync(legacyPath)) {
87
- if (!legacySkillsWarningEmitted) {
88
- legacySkillsWarningEmitted = true;
89
- process.stderr.write(
90
- `[caamp] WARNING: skills root resolved from legacy path ${legacyPath}. Run \`cleo skills doctor migrate\` to move to ~/.cleo/skills/.
91
- `
92
- );
93
- }
94
- return legacyPath;
95
- }
96
- return newPath;
97
- }
98
- function getCanonicalSkillsDir() {
99
- return getCanonicalSkillsRoot();
100
- }
101
71
  function getLockFilePath() {
102
72
  return join(getAgentsHome(), ".caamp-lock.json");
103
73
  }
@@ -245,9 +215,6 @@ export {
245
215
  getPlatformLocations,
246
216
  getAgentsHome,
247
217
  getProjectAgentsDir,
248
- _resetLegacySkillsWarning,
249
- getCanonicalSkillsRoot,
250
- getCanonicalSkillsDir,
251
218
  getLockFilePath,
252
219
  getAgentsMcpDir,
253
220
  getAgentsMcpServersPath,
@@ -264,4 +231,4 @@ export {
264
231
  resolveProvidersRegistryPath,
265
232
  buildSkillSubPathCandidates
266
233
  };
267
- //# sourceMappingURL=chunk-H5YXR2DC.js.map
234
+ //# sourceMappingURL=chunk-HDZYZTR2.js.map
@@ -0,0 +1 @@
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';\n// T9747: caamp no longer owns a canonical-skills helper. Consumers must import\n// `resolveSkillsRoot` from `@cleocode/core/skills/skill-root.js` directly. This\n// module retains `getAgentsHome()` and the `.agents/*` helpers — only the\n// skills override has been severed (the SSoT now lives in core).\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 * 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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