@agents-inc/cli 0.84.1 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-6VGBO6SZ.js → chunk-5M6Q5UQO.js} +2 -2
  3. package/dist/{chunk-YJ2URWF7.js → chunk-B6MYECV6.js} +2 -2
  4. package/dist/{chunk-FT46LN7K.js → chunk-BV2MIQ3O.js} +7 -8
  5. package/dist/chunk-BV2MIQ3O.js.map +1 -0
  6. package/dist/{chunk-G2MINRWX.js → chunk-C5IYJ42F.js} +2 -2
  7. package/dist/{chunk-7UZUDHP7.js → chunk-CXWBVBDM.js} +2 -2
  8. package/dist/chunk-DCVCFBQ7.js +1800 -0
  9. package/dist/chunk-DCVCFBQ7.js.map +1 -0
  10. package/dist/{chunk-CYPCJ536.js → chunk-FBZR46GC.js} +92 -92
  11. package/dist/chunk-FBZR46GC.js.map +1 -0
  12. package/dist/{chunk-TXW257CU.js → chunk-GED2F75H.js} +90 -167
  13. package/dist/chunk-GED2F75H.js.map +1 -0
  14. package/dist/{chunk-LTFGEVTM.js → chunk-HH3AWXF4.js} +3 -3
  15. package/dist/{chunk-2XVLQDNI.js → chunk-HSLVCKVQ.js} +3 -3
  16. package/dist/{chunk-TAQGYJIS.js → chunk-HZ2IBXVQ.js} +3 -3
  17. package/dist/{chunk-LN76TJJP.js → chunk-HZQOFFKA.js} +10 -10
  18. package/dist/{chunk-W7LHI54P.js → chunk-I44YG6VI.js} +2 -2
  19. package/dist/{chunk-L7COG2EX.js → chunk-LZ7XQ3IU.js} +2 -2
  20. package/dist/{chunk-LMR7VAP3.js → chunk-MMTMXLI4.js} +2 -2
  21. package/dist/chunk-N6A7A4RA.js +16 -0
  22. package/dist/chunk-N6A7A4RA.js.map +1 -0
  23. package/dist/{chunk-WJKD6EGK.js → chunk-NUU3U43A.js} +5 -6
  24. package/dist/chunk-NUU3U43A.js.map +1 -0
  25. package/dist/chunk-O5ZWS26C.js +166 -0
  26. package/dist/chunk-O5ZWS26C.js.map +1 -0
  27. package/dist/{chunk-YYIWB42G.js → chunk-Q4DMIPZB.js} +2 -2
  28. package/dist/{chunk-YSLDMYWP.js → chunk-SGZOFIFF.js} +2 -2
  29. package/dist/{chunk-FKXD3EXJ.js → chunk-TMTUTUEV.js} +42 -228
  30. package/dist/chunk-TMTUTUEV.js.map +1 -0
  31. package/dist/{chunk-WCCWQ56J.js → chunk-UNEJKTLP.js} +3 -3
  32. package/dist/chunk-XQK4S22C.js +202 -0
  33. package/dist/chunk-XQK4S22C.js.map +1 -0
  34. package/dist/{chunk-ZGD7PLLC.js → chunk-ZOWRO7UQ.js} +3 -3
  35. package/dist/commands/build/marketplace.js +3 -3
  36. package/dist/commands/build/plugins.js +5 -5
  37. package/dist/commands/build/stack.js +5 -5
  38. package/dist/commands/compile.js +63 -163
  39. package/dist/commands/compile.js.map +1 -1
  40. package/dist/commands/config/index.js +5 -5
  41. package/dist/commands/config/path.js +4 -4
  42. package/dist/commands/config/show.js +5 -5
  43. package/dist/commands/diff.js +27 -632
  44. package/dist/commands/diff.js.map +1 -1
  45. package/dist/commands/doctor.js +41 -28
  46. package/dist/commands/doctor.js.map +1 -1
  47. package/dist/commands/edit.js +128 -194
  48. package/dist/commands/edit.js.map +1 -1
  49. package/dist/commands/eject.js +58 -126
  50. package/dist/commands/eject.js.map +1 -1
  51. package/dist/commands/import/skill.js +15 -148
  52. package/dist/commands/import/skill.js.map +1 -1
  53. package/dist/commands/info.js +34 -85
  54. package/dist/commands/info.js.map +1 -1
  55. package/dist/commands/init.js +23 -17
  56. package/dist/commands/list.js +4 -4
  57. package/dist/commands/new/agent.js +23 -97
  58. package/dist/commands/new/agent.js.map +1 -1
  59. package/dist/commands/new/marketplace.js +9 -9
  60. package/dist/commands/new/marketplace.js.map +1 -1
  61. package/dist/commands/new/skill.js +169 -20
  62. package/dist/commands/new/skill.js.map +1 -1
  63. package/dist/commands/outdated.js +18 -24
  64. package/dist/commands/outdated.js.map +1 -1
  65. package/dist/commands/search.js +37 -100
  66. package/dist/commands/search.js.map +1 -1
  67. package/dist/commands/uninstall.js +39 -156
  68. package/dist/commands/uninstall.js.map +1 -1
  69. package/dist/commands/update.js +49 -99
  70. package/dist/commands/update.js.map +1 -1
  71. package/dist/commands/validate.js +4 -4
  72. package/dist/components/skill-search/skill-search.js +2 -1
  73. package/dist/components/wizard/category-grid.test.js +4 -4
  74. package/dist/components/wizard/domain-selection.js +5 -5
  75. package/dist/components/wizard/help-modal.js +5 -5
  76. package/dist/components/wizard/source-grid.test.js +4 -4
  77. package/dist/components/wizard/stack-selection.js +5 -5
  78. package/dist/components/wizard/step-agents.js +5 -5
  79. package/dist/components/wizard/step-agents.test.js +5 -5
  80. package/dist/components/wizard/step-build.js +5 -5
  81. package/dist/components/wizard/step-build.test.js +5 -5
  82. package/dist/components/wizard/step-confirm.test.js +4 -4
  83. package/dist/components/wizard/step-settings.js +4 -4
  84. package/dist/components/wizard/step-settings.test.js +7 -7
  85. package/dist/components/wizard/step-sources.js +5 -5
  86. package/dist/components/wizard/step-sources.test.js +5 -5
  87. package/dist/components/wizard/step-stack.js +6 -6
  88. package/dist/components/wizard/step-stack.test.js +6 -6
  89. package/dist/components/wizard/wizard-layout.js +6 -6
  90. package/dist/components/wizard/wizard.js +14 -14
  91. package/dist/hooks/init.js +21 -16
  92. package/dist/hooks/init.js.map +1 -1
  93. package/dist/{loader-GT2A7R7U.js → loader-GSEGPK64.js} +3 -3
  94. package/dist/{source-loader-TNQW4P47.js → source-loader-OGFTIRIX.js} +4 -4
  95. package/dist/{source-manager-INRXRFJE.js → source-manager-FMMDDVZA.js} +4 -4
  96. package/dist/stores/wizard-store.js +4 -4
  97. package/dist/stores/wizard-store.test.js +4 -4
  98. package/package.json +1 -1
  99. package/dist/chunk-AABH2HSE.js +0 -340
  100. package/dist/chunk-AABH2HSE.js.map +0 -1
  101. package/dist/chunk-CYPCJ536.js.map +0 -1
  102. package/dist/chunk-FKXD3EXJ.js.map +0 -1
  103. package/dist/chunk-FT46LN7K.js.map +0 -1
  104. package/dist/chunk-TXW257CU.js.map +0 -1
  105. package/dist/chunk-WJKD6EGK.js.map +0 -1
  106. /package/dist/{chunk-6VGBO6SZ.js.map → chunk-5M6Q5UQO.js.map} +0 -0
  107. /package/dist/{chunk-YJ2URWF7.js.map → chunk-B6MYECV6.js.map} +0 -0
  108. /package/dist/{chunk-G2MINRWX.js.map → chunk-C5IYJ42F.js.map} +0 -0
  109. /package/dist/{chunk-7UZUDHP7.js.map → chunk-CXWBVBDM.js.map} +0 -0
  110. /package/dist/{chunk-LTFGEVTM.js.map → chunk-HH3AWXF4.js.map} +0 -0
  111. /package/dist/{chunk-2XVLQDNI.js.map → chunk-HSLVCKVQ.js.map} +0 -0
  112. /package/dist/{chunk-TAQGYJIS.js.map → chunk-HZ2IBXVQ.js.map} +0 -0
  113. /package/dist/{chunk-LN76TJJP.js.map → chunk-HZQOFFKA.js.map} +0 -0
  114. /package/dist/{chunk-W7LHI54P.js.map → chunk-I44YG6VI.js.map} +0 -0
  115. /package/dist/{chunk-L7COG2EX.js.map → chunk-LZ7XQ3IU.js.map} +0 -0
  116. /package/dist/{chunk-LMR7VAP3.js.map → chunk-MMTMXLI4.js.map} +0 -0
  117. /package/dist/{chunk-YYIWB42G.js.map → chunk-Q4DMIPZB.js.map} +0 -0
  118. /package/dist/{chunk-YSLDMYWP.js.map → chunk-SGZOFIFF.js.map} +0 -0
  119. /package/dist/{chunk-WCCWQ56J.js.map → chunk-UNEJKTLP.js.map} +0 -0
  120. /package/dist/{chunk-ZGD7PLLC.js.map → chunk-ZOWRO7UQ.js.map} +0 -0
  121. /package/dist/{loader-GT2A7R7U.js.map → loader-GSEGPK64.js.map} +0 -0
  122. /package/dist/{source-loader-TNQW4P47.js.map → source-loader-OGFTIRIX.js.map} +0 -0
  123. /package/dist/{source-manager-INRXRFJE.js.map → source-manager-FMMDDVZA.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/lib/operations/detect-both-installations.ts","../src/cli/lib/operations/load-source.ts","../src/cli/lib/operations/get-dashboard-data.ts","../src/cli/lib/operations/detect-project.ts","../src/cli/lib/operations/load-agent-defs.ts","../src/cli/lib/operations/copy-local-skills.ts","../src/cli/lib/operations/install-plugin-skills.ts","../src/cli/lib/operations/uninstall-plugin-skills.ts","../src/cli/lib/operations/collect-scoped-skill-dirs.ts","../src/cli/lib/operations/compare-skills.ts","../src/cli/lib/operations/ensure-marketplace.ts","../src/cli/lib/operations/write-project-config.ts","../src/cli/lib/operations/compile-agents.ts","../src/cli/lib/operations/detect-config-changes.ts","../src/cli/lib/operations/update-local-skills.ts","../src/cli/lib/operations/discover-skills.ts","../src/cli/lib/operations/find-skill-match.ts","../node_modules/chalk/source/index.js","../node_modules/chalk/source/vendor/ansi-styles/index.js","../node_modules/chalk/source/vendor/supports-color/index.js","../node_modules/chalk/source/utilities.js","../src/cli/lib/operations/generate-skill-diff.ts","../src/cli/lib/operations/resolve-skill-info.ts","../src/cli/lib/operations/eject-project.ts","../src/cli/lib/operations/uninstall-project.ts","../src/cli/lib/operations/search-skills.ts","../src/cli/lib/operations/scaffold-agent.ts","../src/cli/lib/operations/migrate-plugin-scope.ts","../src/cli/lib/operations/index.ts"],"sourcesContent":["import os from \"os\";\nimport {\n detectGlobalInstallation,\n detectProjectInstallation,\n type Installation,\n} from \"../installation/index.js\";\n\nexport type BothInstallations = {\n global: Installation | null;\n project: Installation | null;\n hasBoth: boolean;\n};\n\n/**\n * Detects both global and project installations.\n *\n * Skips project detection when projectDir is the home directory\n * to avoid double-compile. Returns a convenience `hasBoth` flag\n * used by callers to set scopeFilter on compile passes.\n */\nexport async function detectBothInstallations(projectDir: string): Promise<BothInstallations> {\n const global = await detectGlobalInstallation();\n const project = projectDir === os.homedir() ? null : await detectProjectInstallation(projectDir);\n return { global, project, hasBoth: !!global && !!project };\n}\n","import { loadSkillsMatrixFromSource, type SourceLoadResult } from \"../loading/index.js\";\nimport {\n enableBuffering,\n drainBuffer,\n disableBuffering,\n type StartupMessage,\n} from \"../../utils/logger.js\";\n\nexport type LoadSourceOptions = {\n sourceFlag?: string;\n projectDir: string;\n forceRefresh?: boolean;\n /** When true, enables message buffering and captures startup messages. Default: false. */\n captureStartupMessages?: boolean;\n};\n\nexport type LoadedSource = {\n sourceResult: SourceLoadResult;\n /** Empty array when captureStartupMessages is false. */\n startupMessages: StartupMessage[];\n};\n\n/**\n * Loads the skills matrix from a resolved source.\n *\n * When `captureStartupMessages` is true, wraps the load in buffer mode so\n * warn() calls during loading are captured instead of written to stderr.\n * The caller (init/edit) passes these messages to the Wizard's <Static> block.\n *\n * @throws {Error} If source resolution or fetching fails.\n */\nexport async function loadSource(options: LoadSourceOptions): Promise<LoadedSource> {\n const { sourceFlag, projectDir, forceRefresh, captureStartupMessages } = options;\n\n if (captureStartupMessages) {\n enableBuffering();\n }\n\n let sourceResult: SourceLoadResult;\n try {\n sourceResult = await loadSkillsMatrixFromSource({\n sourceFlag,\n projectDir,\n forceRefresh,\n });\n } catch (error) {\n if (captureStartupMessages) {\n disableBuffering();\n }\n throw error;\n }\n\n let startupMessages: StartupMessage[] = [];\n if (captureStartupMessages) {\n startupMessages = drainBuffer();\n disableBuffering();\n }\n\n return { sourceResult, startupMessages };\n}\n","import { getInstallationInfo } from \"../plugins/plugin-info.js\";\nimport { loadProjectConfig } from \"../configuration/project-config.js\";\nimport { deriveInstallMode } from \"../installation/index.js\";\n\nexport type DashboardData = {\n skillCount: number;\n agentCount: number;\n mode: string;\n source?: string;\n};\n\n/** Gathers dashboard data from the installation and project config. */\nexport async function getDashboardData(projectDir: string): Promise<DashboardData> {\n const [info, loaded] = await Promise.all([getInstallationInfo(), loadProjectConfig(projectDir)]);\n\n // Skill count from config (canonical source of truth for installed skills)\n const skillCount = loaded?.config?.skills?.length ?? 0;\n // Agent count from filesystem (compiled .md files in agents dir)\n const agentCount = info?.agentCount ?? 0;\n const mode =\n info?.mode ?? (loaded?.config?.skills ? deriveInstallMode(loaded.config.skills) : \"local\");\n const source = loaded?.config?.source;\n\n return { skillCount, agentCount, mode, source };\n}\n","import { detectInstallation, type Installation } from \"../installation/index.js\";\nimport { loadProjectConfig } from \"../configuration/index.js\";\nimport type { ProjectConfig } from \"../../types/index.js\";\n\nexport type DetectedProject = {\n installation: Installation;\n config: ProjectConfig | null;\n configPath: string | null;\n};\n\n/**\n * Detects an existing CLI installation and loads its project config.\n *\n * Uses detectInstallation() which checks project-level first, then falls back\n * to global. Returns the installation metadata plus the loaded config.\n *\n * Does NOT throw. Returns null if no installation found.\n * Commands decide how to handle null (error out, warn, etc.).\n */\nexport async function detectProject(projectDir?: string): Promise<DetectedProject | null> {\n const resolvedDir = projectDir ?? process.cwd();\n const installation = await detectInstallation(resolvedDir);\n\n if (!installation) {\n return null;\n }\n\n const loaded = await loadProjectConfig(installation.projectDir);\n\n return {\n installation,\n config: loaded?.config ?? null,\n configPath: loaded?.configPath ?? null,\n };\n}\n","import { getAgentDefinitions } from \"../agents/index.js\";\nimport { loadAllAgents } from \"../loading/index.js\";\nimport { PROJECT_ROOT } from \"../../consts.js\";\nimport type { AgentDefinition, AgentName, AgentSourcePaths } from \"../../types/index.js\";\n\nexport type AgentDefs = {\n /** Merged agent definitions (CLI defaults + source overrides). Source takes precedence. */\n agents: Record<AgentName, AgentDefinition>;\n /** The sourcePath used to load agent partials (for compilation). */\n sourcePath: string;\n /** Full agent source paths (agentsDir, templatesDir, sourcePath). */\n agentSourcePaths: AgentSourcePaths;\n};\n\n/**\n * Loads agent definitions from the CLI and optionally from a remote source.\n *\n * Merges CLI built-in agents with source repository agents (source overrides CLI).\n * Returns the merged definitions plus the source path for compilation.\n */\nexport async function loadAgentDefs(\n agentSource?: string,\n options?: { projectDir?: string; forceRefresh?: boolean },\n): Promise<AgentDefs> {\n const agentSourcePaths = await getAgentDefinitions(agentSource, options);\n const cliAgents = await loadAllAgents(PROJECT_ROOT);\n const sourceAgents = await loadAllAgents(agentSourcePaths.sourcePath);\n const agents: Record<AgentName, AgentDefinition> = { ...cliAgents, ...sourceAgents };\n\n return {\n agents,\n sourcePath: agentSourcePaths.sourcePath,\n agentSourcePaths,\n };\n}\n","import { resolveInstallPaths } from \"../installation/index.js\";\nimport { copySkillsToLocalFlattened, type CopiedSkill } from \"../skills/index.js\";\nimport { ensureDir } from \"../../utils/fs.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\nimport type { SourceLoadResult } from \"../loading/source-loader.js\";\n\nexport type SkillCopyResult = {\n projectCopied: CopiedSkill[];\n globalCopied: CopiedSkill[];\n totalCopied: number;\n};\n\n/**\n * Copies local-source skills to their scope-appropriate directories.\n *\n * Splits skills by scope (project vs global), resolves install paths,\n * ensures directories exist, and copies from source.\n */\nexport async function copyLocalSkills(\n skills: SkillConfig[],\n projectDir: string,\n sourceResult: SourceLoadResult,\n): Promise<SkillCopyResult> {\n const projectLocalSkills = skills.filter((s) => s.scope !== \"global\");\n const globalLocalSkills = skills.filter((s) => s.scope === \"global\");\n\n const projectPaths = resolveInstallPaths(projectDir, \"project\");\n const globalPaths = resolveInstallPaths(projectDir, \"global\");\n\n let projectCopied: CopiedSkill[] = [];\n if (projectLocalSkills.length > 0) {\n await ensureDir(projectPaths.skillsDir);\n projectCopied = await copySkillsToLocalFlattened(\n projectLocalSkills.map((s) => s.id),\n projectPaths.skillsDir,\n sourceResult.matrix,\n sourceResult,\n );\n }\n\n let globalCopied: CopiedSkill[] = [];\n if (globalLocalSkills.length > 0) {\n await ensureDir(globalPaths.skillsDir);\n globalCopied = await copySkillsToLocalFlattened(\n globalLocalSkills.map((s) => s.id),\n globalPaths.skillsDir,\n sourceResult.matrix,\n sourceResult,\n );\n }\n\n return {\n projectCopied,\n globalCopied,\n totalCopied: projectCopied.length + globalCopied.length,\n };\n}\n","import { claudePluginInstall } from \"../../utils/exec.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport type { SkillId } from \"../../types/index.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\n\nexport type PluginInstallResult = {\n installed: Array<{ id: SkillId; ref: string }>;\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/**\n * Installs skill plugins via the Claude CLI, routing by scope.\n *\n * For each skill, constructs the plugin ref as `{skillId}@{marketplace}`\n * and invokes `claudePluginInstall` with the correct scope.\n */\nexport async function installPluginSkills(\n skills: SkillConfig[],\n marketplace: string,\n projectDir: string,\n): Promise<PluginInstallResult> {\n const pluginSkills = skills.filter((s) => s.source !== \"local\");\n const installed: PluginInstallResult[\"installed\"] = [];\n const failed: PluginInstallResult[\"failed\"] = [];\n\n for (const skill of pluginSkills) {\n const pluginRef = `${skill.id}@${marketplace}`;\n const pluginScope = skill.scope === \"global\" ? \"user\" : \"project\";\n try {\n await claudePluginInstall(pluginRef, pluginScope, projectDir);\n installed.push({ id: skill.id, ref: pluginRef });\n } catch (error) {\n failed.push({ id: skill.id, error: getErrorMessage(error) });\n }\n }\n\n return { installed, failed };\n}\n","import { claudePluginUninstall } from \"../../utils/exec.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport type { SkillId } from \"../../types/index.js\";\nimport type { SkillConfig } from \"../../types/config.js\";\n\nexport type PluginUninstallResult = {\n uninstalled: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/**\n * Uninstalls skill plugins via the Claude CLI, using scope from old config.\n */\nexport async function uninstallPluginSkills(\n skillIds: SkillId[],\n oldSkills: SkillConfig[],\n projectDir: string,\n): Promise<PluginUninstallResult> {\n const uninstalled: SkillId[] = [];\n const failed: PluginUninstallResult[\"failed\"] = [];\n\n for (const skillId of skillIds) {\n const oldSkill = oldSkills.find((s) => s.id === skillId);\n const pluginScope = oldSkill?.scope === \"global\" ? \"user\" : \"project\";\n try {\n await claudePluginUninstall(skillId, pluginScope, projectDir);\n uninstalled.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { uninstalled, failed };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport { fileExists, listDirectories } from \"../../utils/fs.js\";\nimport { LOCAL_SKILLS_PATH } from \"../../consts.js\";\n\nexport type ScopedSkillDir = {\n dirName: string;\n localSkillsPath: string;\n scope: \"project\" | \"global\";\n};\n\nexport type ScopedSkillDirsResult = {\n dirs: ScopedSkillDir[];\n hasProject: boolean;\n hasGlobal: boolean;\n projectLocalPath: string;\n globalLocalPath: string;\n};\n\n/**\n * Collects local skill directories from both project and global scopes.\n * Project-scoped dirs take precedence over global on name conflict.\n *\n * @returns directories with scope annotations, plus path/existence metadata\n */\nexport async function collectScopedSkillDirs(projectDir: string): Promise<ScopedSkillDirsResult> {\n const homeDir = os.homedir();\n const projectLocalPath = path.join(projectDir, LOCAL_SKILLS_PATH);\n const globalLocalPath = path.join(homeDir, LOCAL_SKILLS_PATH);\n const hasProject = await fileExists(projectLocalPath);\n const hasGlobal = projectDir !== homeDir && (await fileExists(globalLocalPath));\n\n const dirs: ScopedSkillDir[] = [];\n\n if (hasProject) {\n for (const dirName of await listDirectories(projectLocalPath)) {\n dirs.push({ dirName, localSkillsPath: projectLocalPath, scope: \"project\" });\n }\n }\n\n if (hasGlobal) {\n const projectDirNames = new Set(dirs.map((d) => d.dirName));\n for (const dirName of await listDirectories(globalLocalPath)) {\n if (!projectDirNames.has(dirName)) {\n dirs.push({ dirName, localSkillsPath: globalLocalPath, scope: \"global\" });\n }\n }\n }\n\n return { dirs, hasProject, hasGlobal, projectLocalPath, globalLocalPath };\n}\n","import os from \"os\";\nimport { compareLocalSkillsWithSource, type SkillComparisonResult } from \"../skills/index.js\";\nimport { typedEntries } from \"../../utils/typed-object.js\";\nimport { collectScopedSkillDirs } from \"./collect-scoped-skill-dirs.js\";\nimport type { MergedSkillsMatrix } from \"../../types/index.js\";\n\nexport type SkillComparisonResults = {\n projectResults: SkillComparisonResult[];\n globalResults: SkillComparisonResult[];\n /** Merged results with project taking precedence over global. */\n merged: SkillComparisonResult[];\n};\n\n/**\n * Builds a map of source skill IDs to their paths, excluding local-only skills.\n * Used by both compareSkillsWithSource and diff command.\n */\nexport function buildSourceSkillsMap(matrix: MergedSkillsMatrix): Record<string, { path: string }> {\n const sourceSkills: Record<string, { path: string }> = {};\n for (const [skillId, skill] of typedEntries(matrix.skills)) {\n if (!skill) continue;\n if (!skill.local) {\n sourceSkills[skillId] = { path: skill.path };\n }\n }\n return sourceSkills;\n}\n\n/**\n * Compares local skills (project + global scope) against their source versions.\n *\n * Builds a source skills map from the matrix (excluding local-only skills),\n * runs compareLocalSkillsWithSource for both project and global scopes,\n * and merges results with project taking precedence.\n */\nexport async function compareSkillsWithSource(\n projectDir: string,\n sourcePath: string,\n matrix: MergedSkillsMatrix,\n): Promise<SkillComparisonResults> {\n const sourceSkills = buildSourceSkillsMap(matrix);\n\n const { hasProject, hasGlobal } = await collectScopedSkillDirs(projectDir);\n const homeDir = os.homedir();\n\n const projectResults = hasProject\n ? await compareLocalSkillsWithSource(projectDir, sourcePath, sourceSkills)\n : [];\n\n const globalResults = hasGlobal\n ? await compareLocalSkillsWithSource(homeDir, sourcePath, sourceSkills)\n : [];\n\n const seenIds = new Set(projectResults.map((r) => r.id));\n const merged = [...projectResults, ...globalResults.filter((r) => !seenIds.has(r.id))];\n\n return { projectResults, globalResults, merged };\n}\n","import {\n claudePluginMarketplaceExists,\n claudePluginMarketplaceAdd,\n claudePluginMarketplaceUpdate,\n} from \"../../utils/exec.js\";\nimport { fetchMarketplace } from \"../loading/index.js\";\nimport { warn } from \"../../utils/logger.js\";\nimport type { SourceLoadResult } from \"../loading/source-loader.js\";\n\nexport type MarketplaceResult = {\n /** The resolved marketplace name, or null if no marketplace is configured. */\n marketplace: string | null;\n /** Whether a new marketplace was registered (vs. updated or already existed). */\n registered: boolean;\n};\n\n/**\n * Ensures the marketplace is registered with the Claude CLI.\n *\n * If the marketplace does not exist, registers it. If it exists, updates it.\n * Handles lazy marketplace name resolution when sourceResult.marketplace is undefined.\n *\n * Operation is intentionally SILENT — commands decide what to log based on the\n * `registered` flag.\n */\nexport async function ensureMarketplace(\n sourceResult: SourceLoadResult,\n): Promise<MarketplaceResult> {\n if (!sourceResult.marketplace) {\n try {\n const marketplaceResult = await fetchMarketplace(sourceResult.sourceConfig.source, {});\n sourceResult.marketplace = marketplaceResult.marketplace.name;\n } catch {\n return { marketplace: null, registered: false };\n }\n }\n\n const marketplace = sourceResult.marketplace;\n const exists = await claudePluginMarketplaceExists(marketplace);\n\n if (!exists) {\n const marketplaceSource = sourceResult.sourceConfig.source.replace(/^github:/, \"\");\n await claudePluginMarketplaceAdd(marketplaceSource);\n return { marketplace, registered: true };\n }\n\n try {\n await claudePluginMarketplaceUpdate(marketplace);\n } catch {\n warn(\"Could not update marketplace — continuing with cached version\");\n }\n\n return { marketplace, registered: false };\n}\n","import fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\nimport {\n buildAndMergeConfig,\n writeScopedConfigs,\n resolveInstallPaths,\n} from \"../installation/index.js\";\nimport { loadAllAgents, type SourceLoadResult } from \"../loading/index.js\";\nimport { ensureBlankGlobalConfig } from \"../configuration/config-writer.js\";\nimport { ensureDir } from \"../../utils/fs.js\";\nimport { PROJECT_ROOT } from \"../../consts.js\";\nimport type { ProjectConfig, AgentDefinition, AgentName } from \"../../types/index.js\";\nimport type { WizardResultV2 } from \"../../components/wizard/wizard.js\";\n\nexport type ConfigWriteOptions = {\n wizardResult: WizardResultV2;\n sourceResult: SourceLoadResult;\n projectDir: string;\n sourceFlag?: string;\n /** Pre-loaded agent definitions. If omitted, loads from CLI + source. */\n agents?: Record<AgentName, AgentDefinition>;\n};\n\nexport type ConfigWriteResult = {\n config: ProjectConfig;\n configPath: string;\n globalConfigPath?: string;\n wasMerged: boolean;\n existingConfigPath?: string;\n filesWritten: number;\n};\n\n/**\n * Builds, merges, and writes project configuration files.\n *\n * Handles the full config pipeline:\n * 1. buildAndMergeConfig() — generates config from wizard result, merges with existing\n * 2. loadAllAgents() — loads agent definitions for config-types generation\n * 3. ensureBlankGlobalConfig() — ensures global config exists (when in project context)\n * 4. writeScopedConfigs() — writes config.ts and config-types.ts split by scope\n */\nexport async function writeProjectConfig(options: ConfigWriteOptions): Promise<ConfigWriteResult> {\n const { wizardResult, sourceResult, projectDir, sourceFlag } = options;\n const projectPaths = resolveInstallPaths(projectDir, \"project\");\n\n await ensureDir(path.dirname(projectPaths.configPath));\n\n let agents: Record<AgentName, AgentDefinition>;\n if (options.agents) {\n agents = options.agents;\n } else {\n const cliAgents = await loadAllAgents(PROJECT_ROOT);\n const sourceAgents = await loadAllAgents(sourceResult.sourcePath);\n agents = { ...cliAgents, ...sourceAgents };\n }\n\n const mergeResult = await buildAndMergeConfig(wizardResult, sourceResult, projectDir, sourceFlag);\n const finalConfig = mergeResult.config;\n\n const isProjectContext = fs.realpathSync(projectDir) !== fs.realpathSync(os.homedir());\n\n if (isProjectContext) {\n await ensureBlankGlobalConfig();\n }\n\n await writeScopedConfigs(\n finalConfig,\n sourceResult.matrix,\n agents,\n projectDir,\n projectPaths.configPath,\n isProjectContext,\n );\n\n return {\n config: finalConfig,\n configPath: projectPaths.configPath,\n wasMerged: mergeResult.merged,\n existingConfigPath: mergeResult.existingConfigPath,\n filesWritten: isProjectContext ? 4 : 2,\n };\n}\n","import { recompileAgents } from \"../agents/index.js\";\nimport { loadProjectConfigFromDir } from \"../configuration/index.js\";\nimport { buildAgentScopeMap } from \"../installation/index.js\";\nimport type { AgentName, SkillDefinitionMap } from \"../../types/index.js\";\nimport type { InstallMode } from \"../installation/index.js\";\n\nexport type CompileAgentsOptions = {\n projectDir: string;\n sourcePath: string;\n pluginDir?: string;\n skills?: SkillDefinitionMap;\n agentScopeMap?: Map<AgentName, \"project\" | \"global\">;\n agents?: AgentName[];\n /** When set, loads config and filters agents to only those matching this scope. */\n scopeFilter?: \"project\" | \"global\";\n outputDir?: string;\n installMode?: InstallMode;\n};\n\nexport type CompilationResult = {\n compiled: AgentName[];\n failed: AgentName[];\n warnings: string[];\n};\n\n/**\n * Compiles agent markdown files from templates + skill content.\n *\n * Thin wrapper around recompileAgents() that standardizes options.\n * The caller invokes this once (edit, update) or twice with scopeFilter (compile).\n */\nexport async function compileAgents(options: CompileAgentsOptions): Promise<CompilationResult> {\n let resolvedAgents = options.agents;\n let resolvedAgentScopeMap = options.agentScopeMap;\n\n if (options.scopeFilter) {\n const loadedConfig = await loadProjectConfigFromDir(options.projectDir);\n\n // Auto-build agentScopeMap from config if not provided\n if (!resolvedAgentScopeMap && loadedConfig?.config) {\n resolvedAgentScopeMap = buildAgentScopeMap(loadedConfig.config);\n }\n\n const filteredAgents = loadedConfig?.config?.agents\n ?.filter((a) => a.scope === options.scopeFilter)\n .map((a) => a.name);\n\n if (resolvedAgents && filteredAgents) {\n const filterSet = new Set(filteredAgents);\n resolvedAgents = resolvedAgents.filter((a) => filterSet.has(a));\n } else if (filteredAgents) {\n resolvedAgents = filteredAgents;\n }\n }\n\n const recompileResult = await recompileAgents({\n pluginDir: options.pluginDir ?? options.projectDir,\n sourcePath: options.sourcePath,\n agents: resolvedAgents,\n skills: options.skills,\n projectDir: options.projectDir,\n outputDir: options.outputDir,\n installMode: options.installMode,\n agentScopeMap: resolvedAgentScopeMap,\n });\n\n return {\n compiled: recompileResult.compiled,\n failed: recompileResult.failed,\n warnings: recompileResult.warnings,\n };\n}\n","import type { SkillId, AgentName } from \"../../types/index.js\";\nimport type { ProjectConfig } from \"../../types/index.js\";\nimport type { WizardResultV2 } from \"../../components/wizard/wizard.js\";\n\nexport type ConfigChanges = {\n addedSkills: SkillId[];\n removedSkills: SkillId[];\n addedAgents: AgentName[];\n removedAgents: AgentName[];\n sourceChanges: Map<SkillId, { from: string; to: string }>;\n scopeChanges: Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>;\n agentScopeChanges: Map<AgentName, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>;\n};\n\n/**\n * Computes the diff between an existing project config and a new wizard result.\n *\n * Detects added/removed skills and agents, skill source changes,\n * skill scope changes, and agent scope changes.\n *\n * Pure function - no side effects, no logging.\n */\nexport function detectConfigChanges(\n oldConfig: ProjectConfig | null,\n wizardResult: WizardResultV2,\n currentSkillIds: SkillId[],\n): ConfigChanges {\n const newSkillIds = wizardResult.skills.map((s) => s.id);\n const addedSkills = newSkillIds.filter((id) => !currentSkillIds.includes(id));\n const removedSkills = currentSkillIds.filter((id) => !newSkillIds.includes(id));\n\n const oldAgentNames = oldConfig?.agents?.map((a) => a.name) ?? [];\n const newAgentNames = wizardResult.agentConfigs.map((a) => a.name);\n const addedAgents = newAgentNames.filter((name) => !oldAgentNames.includes(name));\n const removedAgents = oldAgentNames.filter((name) => !newAgentNames.includes(name));\n\n const sourceChanges = new Map<SkillId, { from: string; to: string }>();\n const scopeChanges = new Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>();\n if (oldConfig?.skills) {\n for (const newSkill of wizardResult.skills) {\n const oldSkill = oldConfig.skills.find((s) => s.id === newSkill.id);\n if (oldSkill && oldSkill.source !== newSkill.source) {\n sourceChanges.set(newSkill.id, {\n from: oldSkill.source,\n to: newSkill.source,\n });\n }\n if (oldSkill && oldSkill.scope !== newSkill.scope) {\n scopeChanges.set(newSkill.id, {\n from: oldSkill.scope,\n to: newSkill.scope,\n });\n }\n }\n }\n\n const agentScopeChanges = new Map<\n AgentName,\n { from: \"project\" | \"global\"; to: \"project\" | \"global\" }\n >();\n if (oldConfig?.agents) {\n for (const newAgent of wizardResult.agentConfigs) {\n const oldAgent = oldConfig.agents.find((a) => a.name === newAgent.name);\n if (oldAgent && oldAgent.scope !== newAgent.scope) {\n agentScopeChanges.set(newAgent.name, {\n from: oldAgent.scope,\n to: newAgent.scope,\n });\n }\n }\n }\n\n return {\n addedSkills,\n removedSkills,\n addedAgents,\n removedAgents,\n sourceChanges,\n scopeChanges,\n agentScopeChanges,\n };\n}\n","import path from \"path\";\nimport { copy } from \"../../utils/fs.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport { injectForkedFromMetadata } from \"../skills/index.js\";\nimport { LOCAL_SKILLS_PATH } from \"../../consts.js\";\nimport type { SourceLoadResult } from \"../loading/source-loader.js\";\nimport type { SkillComparisonResult } from \"../skills/index.js\";\n\nexport type SkillUpdateResult = {\n id: string;\n success: boolean;\n newHash: string | null;\n error?: string;\n};\n\nexport type UpdateLocalSkillsResult = {\n updated: SkillUpdateResult[];\n failed: SkillUpdateResult[];\n totalUpdated: number;\n totalFailed: number;\n};\n\nexport type UpdateLocalSkillsOptions = {\n skills: SkillComparisonResult[];\n sourceResult: SourceLoadResult;\n skillBaseDir: Map<string, string>;\n /** Called before each skill update starts. Use for progress logging. */\n onProgress?: (skillId: string) => void;\n};\n\n/**\n * Updates local skills by copying from source and injecting metadata.\n *\n * For each outdated skill, copies the source version to the local skills\n * directory and injects forked-from metadata for change tracking.\n */\nexport async function updateLocalSkills(\n options: UpdateLocalSkillsOptions,\n): Promise<UpdateLocalSkillsResult> {\n const { skills, sourceResult, skillBaseDir, onProgress } = options;\n const updated: SkillUpdateResult[] = [];\n const failed: SkillUpdateResult[] = [];\n\n for (const skill of skills) {\n onProgress?.(skill.id);\n if (!skill.sourcePath || !skill.sourceHash) {\n failed.push({\n id: skill.id,\n success: false,\n newHash: null,\n error: \"No source path available\",\n });\n continue;\n }\n\n const baseDir = skillBaseDir.get(skill.id) ?? process.cwd();\n const localSkillsPath = path.join(baseDir, LOCAL_SKILLS_PATH);\n const destPath = path.join(localSkillsPath, skill.dirName);\n const srcPath = path.join(sourceResult.sourcePath, \"src\", skill.sourcePath);\n\n try {\n await copy(srcPath, destPath);\n await injectForkedFromMetadata(destPath, skill.id, skill.sourceHash);\n updated.push({ id: skill.id, success: true, newHash: skill.sourceHash });\n } catch (error) {\n failed.push({ id: skill.id, success: false, newHash: null, error: getErrorMessage(error) });\n }\n }\n\n return {\n updated,\n failed,\n totalUpdated: updated.length,\n totalFailed: failed.length,\n };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport { discoverAllPluginSkills } from \"../plugins/index.js\";\nimport { directoryExists, glob, readFile, fileExists } from \"../../utils/fs.js\";\nimport { parseFrontmatter } from \"../loading/index.js\";\nimport { verbose, warn } from \"../../utils/logger.js\";\nimport { GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../../consts.js\";\nimport { typedEntries, typedKeys } from \"../../utils/typed-object.js\";\nimport type { SkillDefinition, SkillDefinitionMap, SkillId } from \"../../types/index.js\";\n\nexport type DiscoveredSkills = {\n allSkills: SkillDefinitionMap;\n totalSkillCount: number;\n pluginSkillCount: number;\n localSkillCount: number;\n globalPluginSkillCount: number;\n globalLocalSkillCount: number;\n};\n\n/**\n * Loads SKILL.md files from a directory, parsing frontmatter for skill metadata.\n * Returns a map of skillId -> SkillDefinition.\n */\nexport async function loadSkillsFromDir(\n skillsDir: string,\n pathPrefix = \"\",\n): Promise<SkillDefinitionMap> {\n const skills: SkillDefinitionMap = {};\n\n if (!(await directoryExists(skillsDir))) {\n return skills;\n }\n\n const skillFiles = await glob(\"**/SKILL.md\", skillsDir);\n\n for (const skillFile of skillFiles) {\n const skillPath = path.join(skillsDir, skillFile);\n const skillDir = path.dirname(skillPath);\n const relativePath = path.relative(skillsDir, skillDir);\n const skillDirName = path.basename(skillDir);\n\n const metadataPath = path.join(skillDir, STANDARD_FILES.METADATA_YAML);\n if (!(await fileExists(metadataPath))) {\n const displayPath = pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`;\n warn(\n `Skill '${skillDirName}' in '${displayPath}' is missing ${STANDARD_FILES.METADATA_YAML} — skipped. Add ${STANDARD_FILES.METADATA_YAML} to register it with the CLI.`,\n );\n continue;\n }\n\n try {\n const content = await readFile(skillPath);\n const frontmatter = parseFrontmatter(content, skillPath);\n\n if (!frontmatter?.name) {\n warn(`Skipping skill in '${skillDirName}': missing or invalid frontmatter name`);\n continue;\n }\n\n const canonicalId = frontmatter.name;\n\n const skill: SkillDefinition = {\n id: canonicalId,\n path: pathPrefix ? `${pathPrefix}/${relativePath}/` : `${relativePath}/`,\n description: frontmatter?.description || \"\",\n };\n\n skills[canonicalId] = skill;\n verbose(` Loaded skill: ${canonicalId}`);\n } catch (error) {\n verbose(` Failed to load skill: ${skillFile} - ${error}`);\n }\n }\n\n return skills;\n}\n\n/**\n * Discovers local project skills from the .claude/skills/ directory.\n */\nexport async function discoverLocalProjectSkills(projectDir: string): Promise<SkillDefinitionMap> {\n const localSkillsDir = path.join(projectDir, LOCAL_SKILLS_PATH);\n return loadSkillsFromDir(localSkillsDir, LOCAL_SKILLS_PATH);\n}\n\n/** Merges skill maps — later sources take precedence over earlier ones. */\nexport function mergeSkills(...skillSources: SkillDefinitionMap[]): SkillDefinitionMap {\n const merged: SkillDefinitionMap = {};\n\n for (const source of skillSources) {\n for (const [id, skill] of typedEntries<SkillId, SkillDefinition | undefined>(source)) {\n if (skill) {\n merged[id] = skill;\n }\n }\n }\n\n return merged;\n}\n\n/**\n * Discovers all installed skills for a project directory using 4-way merge:\n * 1. Global plugins (from ~/.claude/plugins/)\n * 2. Global local (from ~/.claude/skills/)\n * 3. Project plugins (from <projectDir>/.claude/plugins/)\n * 4. Project local (from <projectDir>/.claude/skills/)\n *\n * Pure function — no user-facing logging. Callers add their own log messages.\n * Uses verbose() for diagnostic output only.\n */\nexport async function discoverInstalledSkills(projectDir: string): Promise<DiscoveredSkills> {\n const isGlobalProject = projectDir === os.homedir();\n\n // 1. Global plugins\n const globalPluginSkills = isGlobalProject ? {} : await discoverAllPluginSkills(os.homedir());\n const globalPluginSkillCount = typedKeys<SkillId>(globalPluginSkills).length;\n if (globalPluginSkillCount > 0) {\n verbose(` Found ${globalPluginSkillCount} skills from global plugins`);\n }\n\n // 2. Global local skills\n const globalLocalSkillsDir = path.join(GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH);\n const globalLocalSkills = isGlobalProject\n ? {}\n : await loadSkillsFromDir(globalLocalSkillsDir, LOCAL_SKILLS_PATH);\n const globalLocalSkillCount = typedKeys<SkillId>(globalLocalSkills).length;\n if (globalLocalSkillCount > 0) {\n verbose(` Found ${globalLocalSkillCount} global local skills from ~/.claude/skills/`);\n }\n\n // 3. Project plugins\n const pluginSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillCount = typedKeys<SkillId>(pluginSkills).length;\n verbose(` Found ${pluginSkillCount} skills from installed plugins`);\n\n // 4. Project local skills\n const localSkills = await discoverLocalProjectSkills(projectDir);\n const localSkillCount = typedKeys<SkillId>(localSkills).length;\n verbose(` Found ${localSkillCount} local skills from .claude/skills/`);\n\n // Merge: global first, project second — project wins on conflict\n const allSkills = mergeSkills(globalPluginSkills, globalLocalSkills, pluginSkills, localSkills);\n const totalSkillCount = typedKeys<SkillId>(allSkills).length;\n\n return {\n allSkills,\n totalSkillCount,\n pluginSkillCount: globalPluginSkillCount + pluginSkillCount,\n localSkillCount: globalLocalSkillCount + localSkillCount,\n globalPluginSkillCount,\n globalLocalSkillCount,\n };\n}\n","import type { SkillComparisonResult } from \"../skills/index.js\";\n\nexport type SkillMatchResult = {\n match: SkillComparisonResult | null;\n similar: string[];\n};\n\n/**\n * Finds a skill by exact ID, partial name, or directory name.\n * Falls back to fuzzy matching and returns similar suggestions.\n */\nexport function findSkillMatch(\n skillName: string,\n results: SkillComparisonResult[],\n): SkillMatchResult {\n // Exact match by ID\n const exact = results.find((r) => r.id === skillName);\n if (exact) return { match: exact, similar: [] };\n\n // Partial match (without author suffix)\n const partial = results.find((r) => {\n const nameWithoutAuthor = r.id.replace(/\\s*\\(@\\w+\\)$/, \"\").toLowerCase();\n return nameWithoutAuthor === skillName.toLowerCase();\n });\n if (partial) return { match: partial, similar: [] };\n\n // Match by directory name\n const byDir = results.find((r) => r.dirName.toLowerCase() === skillName.toLowerCase());\n if (byDir) return { match: byDir, similar: [] };\n\n // No match — find similar suggestions\n const lowered = skillName.toLowerCase();\n const similar = results\n .filter((r) => {\n const name = r.id.toLowerCase();\n const dir = r.dirName.toLowerCase();\n return (\n name.includes(lowered) || dir.includes(lowered) || lowered.includes(name.split(\" \")[0])\n );\n })\n .map((r) => r.id)\n .slice(0, 3);\n\n return { match: null, similar };\n}\n","import ansiStyles from '#ansi-styles';\nimport supportsColor from '#supports-color';\nimport { // eslint-disable-line import/order\n\tstringReplaceAll,\n\tstringEncaseCRLFWithFirstIndex,\n} from './utilities.js';\n\nconst {stdout: stdoutColor, stderr: stderrColor} = supportsColor;\n\nconst GENERATOR = Symbol('GENERATOR');\nconst STYLER = Symbol('STYLER');\nconst IS_EMPTY = Symbol('IS_EMPTY');\n\n// `supportsColor.level` → `ansiStyles.color[name]` mapping\nconst levelMapping = [\n\t'ansi',\n\t'ansi',\n\t'ansi256',\n\t'ansi16m',\n];\n\nconst styles = Object.create(null);\n\nconst applyOptions = (object, options = {}) => {\n\tif (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {\n\t\tthrow new Error('The `level` option should be an integer from 0 to 3');\n\t}\n\n\t// Detect level if not set manually\n\tconst colorLevel = stdoutColor ? stdoutColor.level : 0;\n\tobject.level = options.level === undefined ? colorLevel : options.level;\n};\n\nexport class Chalk {\n\tconstructor(options) {\n\t\t// eslint-disable-next-line no-constructor-return\n\t\treturn chalkFactory(options);\n\t}\n}\n\nconst chalkFactory = options => {\n\tconst chalk = (...strings) => strings.join(' ');\n\tapplyOptions(chalk, options);\n\n\tObject.setPrototypeOf(chalk, createChalk.prototype);\n\n\treturn chalk;\n};\n\nfunction createChalk(options) {\n\treturn chalkFactory(options);\n}\n\nObject.setPrototypeOf(createChalk.prototype, Function.prototype);\n\nfor (const [styleName, style] of Object.entries(ansiStyles)) {\n\tstyles[styleName] = {\n\t\tget() {\n\t\t\tconst builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);\n\t\t\tObject.defineProperty(this, styleName, {value: builder});\n\t\t\treturn builder;\n\t\t},\n\t};\n}\n\nstyles.visible = {\n\tget() {\n\t\tconst builder = createBuilder(this, this[STYLER], true);\n\t\tObject.defineProperty(this, 'visible', {value: builder});\n\t\treturn builder;\n\t},\n};\n\nconst getModelAnsi = (model, level, type, ...arguments_) => {\n\tif (model === 'rgb') {\n\t\tif (level === 'ansi16m') {\n\t\t\treturn ansiStyles[type].ansi16m(...arguments_);\n\t\t}\n\n\t\tif (level === 'ansi256') {\n\t\t\treturn ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));\n\t\t}\n\n\t\treturn ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));\n\t}\n\n\tif (model === 'hex') {\n\t\treturn getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));\n\t}\n\n\treturn ansiStyles[type][model](...arguments_);\n};\n\nconst usedModels = ['rgb', 'hex', 'ansi256'];\n\nfor (const model of usedModels) {\n\tstyles[model] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n\n\tconst bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n\tstyles[bgModel] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);\n\t\t\t\treturn createBuilder(this, styler, this[IS_EMPTY]);\n\t\t\t};\n\t\t},\n\t};\n}\n\nconst proto = Object.defineProperties(() => {}, {\n\t...styles,\n\tlevel: {\n\t\tenumerable: true,\n\t\tget() {\n\t\t\treturn this[GENERATOR].level;\n\t\t},\n\t\tset(level) {\n\t\t\tthis[GENERATOR].level = level;\n\t\t},\n\t},\n});\n\nconst createStyler = (open, close, parent) => {\n\tlet openAll;\n\tlet closeAll;\n\tif (parent === undefined) {\n\t\topenAll = open;\n\t\tcloseAll = close;\n\t} else {\n\t\topenAll = parent.openAll + open;\n\t\tcloseAll = close + parent.closeAll;\n\t}\n\n\treturn {\n\t\topen,\n\t\tclose,\n\t\topenAll,\n\t\tcloseAll,\n\t\tparent,\n\t};\n};\n\nconst createBuilder = (self, _styler, _isEmpty) => {\n\t// Single argument is hot path, implicit coercion is faster than anything\n\t// eslint-disable-next-line no-implicit-coercion\n\tconst builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));\n\n\t// We alter the prototype because we must return a function, but there is\n\t// no way to create a function with a different prototype\n\tObject.setPrototypeOf(builder, proto);\n\n\tbuilder[GENERATOR] = self;\n\tbuilder[STYLER] = _styler;\n\tbuilder[IS_EMPTY] = _isEmpty;\n\n\treturn builder;\n};\n\nconst applyStyle = (self, string) => {\n\tif (self.level <= 0 || !string) {\n\t\treturn self[IS_EMPTY] ? '' : string;\n\t}\n\n\tlet styler = self[STYLER];\n\n\tif (styler === undefined) {\n\t\treturn string;\n\t}\n\n\tconst {openAll, closeAll} = styler;\n\tif (string.includes('\\u001B')) {\n\t\twhile (styler !== undefined) {\n\t\t\t// Replace any instances already present with a re-opening code\n\t\t\t// otherwise only the part of the string until said closing code\n\t\t\t// will be colored, and the rest will simply be 'plain'.\n\t\t\tstring = stringReplaceAll(string, styler.close, styler.open);\n\n\t\t\tstyler = styler.parent;\n\t\t}\n\t}\n\n\t// We can move both next actions out of loop, because remaining actions in loop won't have\n\t// any/visible effect on parts we add here. Close the styling before a linebreak and reopen\n\t// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92\n\tconst lfIndex = string.indexOf('\\n');\n\tif (lfIndex !== -1) {\n\t\tstring = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);\n\t}\n\n\treturn openAll + string + closeAll;\n};\n\nObject.defineProperties(createChalk.prototype, styles);\n\nconst chalk = createChalk();\nexport const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});\n\nexport {\n\tmodifierNames,\n\tforegroundColorNames,\n\tbackgroundColorNames,\n\tcolorNames,\n\n\t// TODO: Remove these aliases in the next major version\n\tmodifierNames as modifiers,\n\tforegroundColorNames as foregroundColors,\n\tbackgroundColorNames as backgroundColors,\n\tcolorNames as colors,\n} from './vendor/ansi-styles/index.js';\n\nexport {\n\tstdoutColor as supportsColor,\n\tstderrColor as supportsColorStderr,\n};\n\nexport default chalk;\n","const ANSI_BACKGROUND_OFFSET = 10;\n\nconst wrapAnsi16 = (offset = 0) => code => `\\u001B[${code + offset}m`;\n\nconst wrapAnsi256 = (offset = 0) => code => `\\u001B[${38 + offset};5;${code}m`;\n\nconst wrapAnsi16m = (offset = 0) => (red, green, blue) => `\\u001B[${38 + offset};2;${red};${green};${blue}m`;\n\nconst styles = {\n\tmodifier: {\n\t\treset: [0, 0],\n\t\t// 21 isn't widely supported and 22 does the same thing\n\t\tbold: [1, 22],\n\t\tdim: [2, 22],\n\t\titalic: [3, 23],\n\t\tunderline: [4, 24],\n\t\toverline: [53, 55],\n\t\tinverse: [7, 27],\n\t\thidden: [8, 28],\n\t\tstrikethrough: [9, 29],\n\t},\n\tcolor: {\n\t\tblack: [30, 39],\n\t\tred: [31, 39],\n\t\tgreen: [32, 39],\n\t\tyellow: [33, 39],\n\t\tblue: [34, 39],\n\t\tmagenta: [35, 39],\n\t\tcyan: [36, 39],\n\t\twhite: [37, 39],\n\n\t\t// Bright color\n\t\tblackBright: [90, 39],\n\t\tgray: [90, 39], // Alias of `blackBright`\n\t\tgrey: [90, 39], // Alias of `blackBright`\n\t\tredBright: [91, 39],\n\t\tgreenBright: [92, 39],\n\t\tyellowBright: [93, 39],\n\t\tblueBright: [94, 39],\n\t\tmagentaBright: [95, 39],\n\t\tcyanBright: [96, 39],\n\t\twhiteBright: [97, 39],\n\t},\n\tbgColor: {\n\t\tbgBlack: [40, 49],\n\t\tbgRed: [41, 49],\n\t\tbgGreen: [42, 49],\n\t\tbgYellow: [43, 49],\n\t\tbgBlue: [44, 49],\n\t\tbgMagenta: [45, 49],\n\t\tbgCyan: [46, 49],\n\t\tbgWhite: [47, 49],\n\n\t\t// Bright color\n\t\tbgBlackBright: [100, 49],\n\t\tbgGray: [100, 49], // Alias of `bgBlackBright`\n\t\tbgGrey: [100, 49], // Alias of `bgBlackBright`\n\t\tbgRedBright: [101, 49],\n\t\tbgGreenBright: [102, 49],\n\t\tbgYellowBright: [103, 49],\n\t\tbgBlueBright: [104, 49],\n\t\tbgMagentaBright: [105, 49],\n\t\tbgCyanBright: [106, 49],\n\t\tbgWhiteBright: [107, 49],\n\t},\n};\n\nexport const modifierNames = Object.keys(styles.modifier);\nexport const foregroundColorNames = Object.keys(styles.color);\nexport const backgroundColorNames = Object.keys(styles.bgColor);\nexport const colorNames = [...foregroundColorNames, ...backgroundColorNames];\n\nfunction assembleStyles() {\n\tconst codes = new Map();\n\n\tfor (const [groupName, group] of Object.entries(styles)) {\n\t\tfor (const [styleName, style] of Object.entries(group)) {\n\t\t\tstyles[styleName] = {\n\t\t\t\topen: `\\u001B[${style[0]}m`,\n\t\t\t\tclose: `\\u001B[${style[1]}m`,\n\t\t\t};\n\n\t\t\tgroup[styleName] = styles[styleName];\n\n\t\t\tcodes.set(style[0], style[1]);\n\t\t}\n\n\t\tObject.defineProperty(styles, groupName, {\n\t\t\tvalue: group,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\n\tObject.defineProperty(styles, 'codes', {\n\t\tvalue: codes,\n\t\tenumerable: false,\n\t});\n\n\tstyles.color.close = '\\u001B[39m';\n\tstyles.bgColor.close = '\\u001B[49m';\n\n\tstyles.color.ansi = wrapAnsi16();\n\tstyles.color.ansi256 = wrapAnsi256();\n\tstyles.color.ansi16m = wrapAnsi16m();\n\tstyles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);\n\tstyles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);\n\n\t// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js\n\tObject.defineProperties(styles, {\n\t\trgbToAnsi256: {\n\t\t\tvalue(red, green, blue) {\n\t\t\t\t// We use the extended greyscale palette here, with the exception of\n\t\t\t\t// black and white. normal palette only has 4 greyscale shades.\n\t\t\t\tif (red === green && green === blue) {\n\t\t\t\t\tif (red < 8) {\n\t\t\t\t\t\treturn 16;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (red > 248) {\n\t\t\t\t\t\treturn 231;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Math.round(((red - 8) / 247) * 24) + 232;\n\t\t\t\t}\n\n\t\t\t\treturn 16\n\t\t\t\t\t+ (36 * Math.round(red / 255 * 5))\n\t\t\t\t\t+ (6 * Math.round(green / 255 * 5))\n\t\t\t\t\t+ Math.round(blue / 255 * 5);\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToRgb: {\n\t\t\tvalue(hex) {\n\t\t\t\tconst matches = /[a-f\\d]{6}|[a-f\\d]{3}/i.exec(hex.toString(16));\n\t\t\t\tif (!matches) {\n\t\t\t\t\treturn [0, 0, 0];\n\t\t\t\t}\n\n\t\t\t\tlet [colorString] = matches;\n\n\t\t\t\tif (colorString.length === 3) {\n\t\t\t\t\tcolorString = [...colorString].map(character => character + character).join('');\n\t\t\t\t}\n\n\t\t\t\tconst integer = Number.parseInt(colorString, 16);\n\n\t\t\t\treturn [\n\t\t\t\t\t/* eslint-disable no-bitwise */\n\t\t\t\t\t(integer >> 16) & 0xFF,\n\t\t\t\t\t(integer >> 8) & 0xFF,\n\t\t\t\t\tinteger & 0xFF,\n\t\t\t\t\t/* eslint-enable no-bitwise */\n\t\t\t\t];\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi256: {\n\t\t\tvalue: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t\tansi256ToAnsi: {\n\t\t\tvalue(code) {\n\t\t\t\tif (code < 8) {\n\t\t\t\t\treturn 30 + code;\n\t\t\t\t}\n\n\t\t\t\tif (code < 16) {\n\t\t\t\t\treturn 90 + (code - 8);\n\t\t\t\t}\n\n\t\t\t\tlet red;\n\t\t\t\tlet green;\n\t\t\t\tlet blue;\n\n\t\t\t\tif (code >= 232) {\n\t\t\t\t\tred = (((code - 232) * 10) + 8) / 255;\n\t\t\t\t\tgreen = red;\n\t\t\t\t\tblue = red;\n\t\t\t\t} else {\n\t\t\t\t\tcode -= 16;\n\n\t\t\t\t\tconst remainder = code % 36;\n\n\t\t\t\t\tred = Math.floor(code / 36) / 5;\n\t\t\t\t\tgreen = Math.floor(remainder / 6) / 5;\n\t\t\t\t\tblue = (remainder % 6) / 5;\n\t\t\t\t}\n\n\t\t\t\tconst value = Math.max(red, green, blue) * 2;\n\n\t\t\t\tif (value === 0) {\n\t\t\t\t\treturn 30;\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tlet result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));\n\n\t\t\t\tif (value === 2) {\n\t\t\t\t\tresult += 60;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t\trgbToAnsi: {\n\t\t\tvalue: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),\n\t\t\tenumerable: false,\n\t\t},\n\t\thexToAnsi: {\n\t\t\tvalue: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),\n\t\t\tenumerable: false,\n\t\t},\n\t});\n\n\treturn styles;\n}\n\nconst ansiStyles = assembleStyles();\n\nexport default ansiStyles;\n","import process from 'node:process';\nimport os from 'node:os';\nimport tty from 'node:tty';\n\n// From: https://github.com/sindresorhus/has-flag/blob/main/index.js\n/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {\nfunction hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {\n\tconst prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');\n\tconst position = argv.indexOf(prefix + flag);\n\tconst terminatorPosition = argv.indexOf('--');\n\treturn position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n}\n\nconst {env} = process;\n\nlet flagForceColor;\nif (\n\thasFlag('no-color')\n\t|| hasFlag('no-colors')\n\t|| hasFlag('color=false')\n\t|| hasFlag('color=never')\n) {\n\tflagForceColor = 0;\n} else if (\n\thasFlag('color')\n\t|| hasFlag('colors')\n\t|| hasFlag('color=true')\n\t|| hasFlag('color=always')\n) {\n\tflagForceColor = 1;\n}\n\nfunction envForceColor() {\n\tif ('FORCE_COLOR' in env) {\n\t\tif (env.FORCE_COLOR === 'true') {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (env.FORCE_COLOR === 'false') {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);\n\t}\n}\n\nfunction translateLevel(level) {\n\tif (level === 0) {\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tlevel,\n\t\thasBasic: true,\n\t\thas256: level >= 2,\n\t\thas16m: level >= 3,\n\t};\n}\n\nfunction _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {\n\tconst noFlagForceColor = envForceColor();\n\tif (noFlagForceColor !== undefined) {\n\t\tflagForceColor = noFlagForceColor;\n\t}\n\n\tconst forceColor = sniffFlags ? flagForceColor : noFlagForceColor;\n\n\tif (forceColor === 0) {\n\t\treturn 0;\n\t}\n\n\tif (sniffFlags) {\n\t\tif (hasFlag('color=16m')\n\t\t\t|| hasFlag('color=full')\n\t\t\t|| hasFlag('color=truecolor')) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (hasFlag('color=256')) {\n\t\t\treturn 2;\n\t\t}\n\t}\n\n\t// Check for Azure DevOps pipelines.\n\t// Has to be above the `!streamIsTTY` check.\n\tif ('TF_BUILD' in env && 'AGENT_NAME' in env) {\n\t\treturn 1;\n\t}\n\n\tif (haveStream && !streamIsTTY && forceColor === undefined) {\n\t\treturn 0;\n\t}\n\n\tconst min = forceColor || 0;\n\n\tif (env.TERM === 'dumb') {\n\t\treturn min;\n\t}\n\n\tif (process.platform === 'win32') {\n\t\t// Windows 10 build 10586 is the first Windows release that supports 256 colors.\n\t\t// Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n\t\tconst osRelease = os.release().split('.');\n\t\tif (\n\t\t\tNumber(osRelease[0]) >= 10\n\t\t\t&& Number(osRelease[2]) >= 10_586\n\t\t) {\n\t\t\treturn Number(osRelease[2]) >= 14_931 ? 3 : 2;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif ('CI' in env) {\n\t\tif (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {\n\t\t\treturn 3;\n\t\t}\n\n\t\tif (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn min;\n\t}\n\n\tif ('TEAMCITY_VERSION' in env) {\n\t\treturn /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;\n\t}\n\n\tif (env.COLORTERM === 'truecolor') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-kitty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'xterm-ghostty') {\n\t\treturn 3;\n\t}\n\n\tif (env.TERM === 'wezterm') {\n\t\treturn 3;\n\t}\n\n\tif ('TERM_PROGRAM' in env) {\n\t\tconst version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);\n\n\t\tswitch (env.TERM_PROGRAM) {\n\t\t\tcase 'iTerm.app': {\n\t\t\t\treturn version >= 3 ? 3 : 2;\n\t\t\t}\n\n\t\t\tcase 'Apple_Terminal': {\n\t\t\t\treturn 2;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\n\tif (/-256(color)?$/i.test(env.TERM)) {\n\t\treturn 2;\n\t}\n\n\tif (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {\n\t\treturn 1;\n\t}\n\n\tif ('COLORTERM' in env) {\n\t\treturn 1;\n\t}\n\n\treturn min;\n}\n\nexport function createSupportsColor(stream, options = {}) {\n\tconst level = _supportsColor(stream, {\n\t\tstreamIsTTY: stream && stream.isTTY,\n\t\t...options,\n\t});\n\n\treturn translateLevel(level);\n}\n\nconst supportsColor = {\n\tstdout: createSupportsColor({isTTY: tty.isatty(1)}),\n\tstderr: createSupportsColor({isTTY: tty.isatty(2)}),\n};\n\nexport default supportsColor;\n","// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.\nexport function stringReplaceAll(string, substring, replacer) {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.slice(endIndex, index) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n\nexport function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n","import path from \"path\";\nimport chalk from \"chalk\";\nimport { createTwoFilesPatch } from \"diff\";\nimport { readForkedFromMetadata, type ForkedFromMetadata } from \"../skills/index.js\";\nimport { fileExists, readFile } from \"../../utils/fs.js\";\nimport { LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../../consts.js\";\n\nexport type SkillDiffResult = {\n skillDirName: string;\n forkedFrom: ForkedFromMetadata | null;\n hasDiff: boolean;\n diffOutput: string;\n};\n\n/**\n * Generates a unified diff between a local skill and its source version.\n *\n * Reads forkedFrom metadata to find the original skill ID, locates the source\n * SKILL.md, and produces a unified diff patch.\n */\nexport async function generateSkillDiff(\n localSkillsPath: string,\n skillDirName: string,\n sourcePath: string,\n sourceSkills: Record<string, { path: string }>,\n): Promise<SkillDiffResult> {\n const skillDir = path.join(localSkillsPath, skillDirName);\n const forkedFrom = await readForkedFromMetadata(skillDir);\n\n if (!forkedFrom) {\n return {\n skillDirName,\n forkedFrom: null,\n hasDiff: false,\n diffOutput: \"\",\n };\n }\n\n const sourceSkill = sourceSkills[forkedFrom.skillId];\n\n if (!sourceSkill) {\n return {\n skillDirName,\n forkedFrom,\n hasDiff: false,\n diffOutput: `Source skill '${forkedFrom.skillId}' no longer exists`,\n };\n }\n\n const sourceSkillMdPath = path.join(sourcePath, \"src\", sourceSkill.path, STANDARD_FILES.SKILL_MD);\n\n if (!(await fileExists(sourceSkillMdPath))) {\n return {\n skillDirName,\n forkedFrom,\n hasDiff: false,\n diffOutput: `Source ${STANDARD_FILES.SKILL_MD} not found at ${sourceSkillMdPath}`,\n };\n }\n\n const sourceContent = await readFile(sourceSkillMdPath);\n\n const localSkillMdPath = path.join(skillDir, STANDARD_FILES.SKILL_MD);\n\n if (!(await fileExists(localSkillMdPath))) {\n return {\n skillDirName,\n forkedFrom,\n hasDiff: false,\n diffOutput: `Local ${STANDARD_FILES.SKILL_MD} not found at ${localSkillMdPath}`,\n };\n }\n\n const localContent = await readFile(localSkillMdPath);\n\n const sourceLabel = `source/${sourceSkill.path}/SKILL.md`;\n const localLabel = `local/${LOCAL_SKILLS_PATH}/${skillDirName}/SKILL.md`;\n\n const diff = createTwoFilesPatch(\n sourceLabel,\n localLabel,\n sourceContent,\n localContent,\n \"\", // No source header\n \"\", // No local header\n );\n\n const hasDiff = diff.split(\"\\n\").some((line) => {\n return (\n (line.startsWith(\"+\") || line.startsWith(\"-\")) &&\n !line.startsWith(\"+++\") &&\n !line.startsWith(\"---\")\n );\n });\n\n return {\n skillDirName,\n forkedFrom,\n hasDiff,\n diffOutput: diff,\n };\n}\n\n/**\n * Colorizes a unified diff string for terminal display.\n * Applies chalk formatting: bold for file headers, green for additions,\n * red for removals, cyan for hunk headers.\n */\nexport function formatColoredDiff(diffText: string): string {\n return diffText\n .split(\"\\n\")\n .map((line) => {\n if (line.startsWith(\"+++\") || line.startsWith(\"---\")) {\n return chalk.bold(line);\n }\n if (line.startsWith(\"+\")) {\n return chalk.green(line);\n }\n if (line.startsWith(\"-\")) {\n return chalk.red(line);\n }\n if (line.startsWith(\"@@\")) {\n return chalk.cyan(line);\n }\n return line;\n })\n .join(\"\\n\");\n}\n","import path from \"path\";\nimport { fileExists, readFile } from \"../../utils/fs.js\";\nimport { discoverLocalSkills } from \"../skills/index.js\";\nimport { STANDARD_FILES } from \"../../consts.js\";\nimport type { ResolvedSkill, SkillId, SkillSlug } from \"../../types/index.js\";\nimport { truncateText } from \"../../utils/string.js\";\n\nconst CONTENT_PREVIEW_LINES = 10;\nconst MAX_LINE_LENGTH = 80;\nconst MAX_SUGGESTIONS = 5;\n\nexport type ResolvedSkillInfo = {\n skill: ResolvedSkill;\n isInstalled: boolean;\n preview: string[];\n};\n\nexport type SkillInfoResult = {\n resolved: ResolvedSkillInfo | null;\n suggestions: string[];\n};\n\nexport type ResolveSkillInfoOptions = {\n /** The skill ID, slug, or search query from user input */\n query: string;\n /** Full skills map from the loaded matrix */\n skills: Partial<Record<SkillId, ResolvedSkill>>;\n /** Slug-to-ID lookup map from the loaded matrix */\n slugToId: Partial<Record<SkillSlug, SkillId>>;\n /** Project directory for local skill discovery */\n projectDir: string;\n /** Resolved source path from loadSource */\n sourcePath: string;\n /** Whether the source is local */\n isLocal: boolean;\n /** Whether to load the content preview */\n includePreview: boolean;\n};\n\n/**\n * Strips YAML frontmatter delimiters and content from markdown.\n */\nfunction stripFrontmatter(content: string): string {\n const lines = content.split(\"\\n\");\n let inFrontmatter = false;\n let frontmatterEndIndex = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim();\n if (line === \"---\") {\n if (!inFrontmatter) {\n inFrontmatter = true;\n } else {\n frontmatterEndIndex = i + 1;\n break;\n }\n }\n }\n\n return lines.slice(frontmatterEndIndex).join(\"\\n\");\n}\n\n/**\n * Extracts the first N non-empty lines from markdown content (after frontmatter).\n */\nfunction getPreviewLines(content: string, maxLines: number): string[] {\n const body = stripFrontmatter(content);\n const lines = body.split(\"\\n\");\n const result: string[] = [];\n\n for (const line of lines) {\n if (result.length >= maxLines) break;\n if (line.trim() || result.length > 0) {\n result.push(truncateText(line, MAX_LINE_LENGTH));\n }\n }\n\n return result;\n}\n\n/**\n * Finds similar skill names for \"did you mean\" suggestions.\n */\nfunction findSuggestions(\n skills: Partial<Record<SkillId, ResolvedSkill>>,\n query: string,\n maxSuggestions: number,\n): string[] {\n const lowerQuery = query.toLowerCase();\n const matches: string[] = [];\n\n for (const skill of Object.values(skills)) {\n if (!skill) continue;\n if (matches.length >= maxSuggestions) break;\n if (\n skill.id.toLowerCase().includes(lowerQuery) ||\n skill.displayName.toLowerCase().includes(lowerQuery) ||\n skill.slug.toLowerCase().includes(lowerQuery)\n ) {\n matches.push(skill.id);\n }\n }\n\n return matches;\n}\n\n/**\n * Resolves complete skill information for display.\n *\n * Looks up the skill by ID or slug, discovers local installation status,\n * and optionally loads a content preview from SKILL.md.\n */\nexport async function resolveSkillInfo(options: ResolveSkillInfoOptions): Promise<SkillInfoResult> {\n const { query, skills, slugToId, projectDir, sourcePath, isLocal, includePreview } = options;\n\n // CLI arg is an untyped string — try as skill ID first, then as slug\n const slugResolvedId = slugToId[query as SkillSlug];\n const skill = skills[query as SkillId] ?? (slugResolvedId ? skills[slugResolvedId] : undefined);\n\n if (!skill) {\n const suggestions = findSuggestions(skills, query, MAX_SUGGESTIONS);\n return { resolved: null, suggestions };\n }\n\n const localSkillsResult = await discoverLocalSkills(projectDir);\n const localSkillIds = localSkillsResult?.skills.map((s) => s.id) || [];\n const isInstalled = localSkillIds.includes(skill.id);\n\n let preview: string[] = [];\n if (includePreview) {\n let skillMdPath: string;\n\n if (skill.local && skill.localPath) {\n skillMdPath = path.join(projectDir, skill.localPath, STANDARD_FILES.SKILL_MD);\n } else {\n const sourceDir = isLocal ? sourcePath : path.dirname(sourcePath);\n skillMdPath = path.join(sourceDir, skill.path, STANDARD_FILES.SKILL_MD);\n }\n\n if (await fileExists(skillMdPath)) {\n const content = await readFile(skillMdPath);\n preview = getPreviewLines(content, CONTENT_PREVIEW_LINES);\n }\n }\n\n return {\n resolved: { skill, isInstalled, preview },\n suggestions: [],\n };\n}\n","import path from \"path\";\nimport {\n copy,\n ensureDir,\n directoryExists,\n fileExists,\n listDirectories,\n writeFile,\n} from \"../../utils/fs.js\";\nimport {\n CLAUDE_SRC_DIR,\n DIRS,\n LOCAL_SKILLS_PATH,\n PROJECT_ROOT,\n STANDARD_FILES,\n} from \"../../consts.js\";\nimport { copySkillsToLocalFlattened, type CopiedSkill } from \"../skills/index.js\";\nimport { resolveSource, loadProjectSourceConfig } from \"../configuration/index.js\";\nimport type { SourceLoadResult } from \"../loading/index.js\";\nimport type { MergedSkillsMatrix, SkillId } from \"../../types/index.js\";\nimport { typedKeys } from \"../../utils/typed-object.js\";\n\n// ---------------------------------------------------------------------------\n// ejectAgentPartials\n// ---------------------------------------------------------------------------\n\nexport type EjectAgentPartialsOptions = {\n outputBase: string;\n force: boolean;\n /** When true, outputBase is used directly as the destination (no subdirectory nesting). */\n directOutput?: boolean;\n /** When true, ejects only the _templates directory instead of the full agents directory. */\n templatesOnly?: boolean;\n};\n\nexport type EjectAgentPartialsResult = {\n /** Whether the operation was skipped (e.g. destination already exists without --force). */\n skipped: boolean;\n /** Human-readable reason when skipped. */\n skipReason?: string;\n /** Destination directory that was written to (undefined when skipped). */\n destDir?: string;\n /** Whether templates were skipped during a full agent-partials eject (existing templates preserved). */\n templatesSkipped: boolean;\n};\n\n/**\n * Copies agent partials or templates from the CLI source to a target directory.\n *\n * When `templatesOnly` is true, copies only the _templates subdirectory.\n * When false, copies the full agents directory (optionally skipping existing templates).\n *\n * Returns structured data — the command decides what to log.\n */\nexport async function ejectAgentPartials(\n options: EjectAgentPartialsOptions,\n): Promise<EjectAgentPartialsResult> {\n const { outputBase, force, directOutput = false, templatesOnly = false } = options;\n\n const sourceDir = templatesOnly\n ? path.join(PROJECT_ROOT, DIRS.templates)\n : path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(sourceDir))) {\n return {\n skipped: true,\n skipReason: templatesOnly\n ? \"No agent templates found in CLI.\"\n : \"No agent partials found in CLI.\",\n templatesSkipped: false,\n };\n }\n\n const destDir = directOutput\n ? outputBase\n : templatesOnly\n ? path.join(outputBase, path.basename(DIRS.agents), path.basename(DIRS.templates))\n : path.join(outputBase, path.basename(DIRS.agents));\n\n const templatesBasename = path.basename(DIRS.templates);\n\n if ((await directoryExists(destDir)) && !force) {\n if (templatesOnly) {\n return {\n skipped: true,\n skipReason: `Agent templates already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n\n const hasTemplates = await directoryExists(path.join(destDir, templatesBasename));\n if ((await hasAgentPartialDirs(destDir)) && !hasTemplates) {\n return {\n skipped: true,\n skipReason: `Agent partials already exist at ${destDir}. Use --force to overwrite.`,\n templatesSkipped: false,\n };\n }\n }\n\n await ensureDir(destDir);\n\n const skipTemplates =\n !templatesOnly && !force && (await directoryExists(path.join(destDir, templatesBasename)));\n\n if (skipTemplates) {\n const sourceEntries = await listDirectories(sourceDir);\n const nonTemplateEntries = sourceEntries.filter((entry) => entry !== templatesBasename);\n for (const entry of nonTemplateEntries) {\n await copy(path.join(sourceDir, entry), path.join(destDir, entry));\n }\n } else {\n await copy(sourceDir, destDir);\n }\n\n return {\n skipped: false,\n destDir,\n templatesSkipped: skipTemplates,\n };\n}\n\n// ---------------------------------------------------------------------------\n// ejectSkills\n// ---------------------------------------------------------------------------\n\nexport type EjectSkillsOptions = {\n projectDir: string;\n force: boolean;\n sourceResult: SourceLoadResult;\n matrix: MergedSkillsMatrix;\n /** When true, uses customOutputBase as destination instead of LOCAL_SKILLS_PATH. */\n directOutput?: boolean;\n customOutputBase?: string;\n};\n\nexport type EjectSkillsResult = {\n /** Whether the operation was skipped. */\n skipped: boolean;\n /** Human-readable reason when skipped. */\n skipReason?: string;\n /** Array of skills that were copied. */\n copiedSkills: CopiedSkill[];\n /** Destination directory that was written to. */\n destDir?: string;\n /** Label describing the source that skills were copied from. */\n sourceLabel?: string;\n};\n\n/**\n * Copies non-local skills from source to a target directory.\n *\n * Filters out skills already marked as local, then copies the remaining skills\n * using copySkillsToLocalFlattened.\n *\n * Returns structured data — the command decides what to log.\n */\nexport async function ejectSkills(options: EjectSkillsOptions): Promise<EjectSkillsResult> {\n const {\n projectDir,\n force,\n sourceResult,\n matrix,\n directOutput = false,\n customOutputBase,\n } = options;\n\n const destDir =\n directOutput && customOutputBase ? customOutputBase : path.join(projectDir, LOCAL_SKILLS_PATH);\n\n if ((await directoryExists(destDir)) && !force) {\n return {\n skipped: true,\n skipReason: `Skills already exist at ${destDir}. Use --force to overwrite.`,\n copiedSkills: [],\n };\n }\n\n const skillIds = typedKeys<SkillId>(matrix.skills).filter(\n (skillId) => !matrix.skills[skillId]?.local,\n );\n\n if (skillIds.length === 0) {\n return {\n skipped: true,\n skipReason: \"No skills found in source to eject.\",\n copiedSkills: [],\n };\n }\n\n await ensureDir(destDir);\n\n const copiedSkills = await copySkillsToLocalFlattened(skillIds, destDir, matrix, sourceResult);\n\n const sourceLabel = sourceResult.isLocal\n ? sourceResult.sourcePath\n : sourceResult.marketplace || sourceResult.sourceConfig.source;\n\n return {\n skipped: false,\n copiedSkills,\n destDir,\n sourceLabel,\n };\n}\n\n// ---------------------------------------------------------------------------\n// ensureMinimalConfig\n// ---------------------------------------------------------------------------\n\nexport type EnsureMinimalConfigOptions = {\n projectDir: string;\n sourceFlag?: string;\n sourceResult?: SourceLoadResult;\n};\n\nexport type EnsureMinimalConfigResult = {\n /** Path to the config file. */\n configPath: string;\n /** Whether a new config was created. */\n created: boolean;\n};\n\n/**\n * Ensures a minimal config.ts exists so `agentsinc compile` works after eject.\n *\n * If the config already exists, returns immediately with `created: false`.\n * Otherwise generates a minimal config from the resolved source and project metadata.\n *\n * Returns structured data — the command decides what to log.\n */\nexport async function ensureMinimalConfig(\n options: EnsureMinimalConfigOptions,\n): Promise<EnsureMinimalConfigResult> {\n const { projectDir, sourceFlag, sourceResult } = options;\n\n const tsConfigPath = path.join(projectDir, CLAUDE_SRC_DIR, STANDARD_FILES.CONFIG_TS);\n\n if (await fileExists(tsConfigPath)) {\n return { configPath: tsConfigPath, created: false };\n }\n\n const projectName = path.basename(projectDir);\n\n const config: Record<string, unknown> = {\n name: projectName,\n };\n\n const resolvedConfig =\n sourceResult?.sourceConfig ?? (await resolveSource(sourceFlag, projectDir));\n\n if (sourceFlag) {\n config.source = sourceFlag;\n } else if (resolvedConfig.source) {\n config.source = resolvedConfig.source;\n }\n\n if (resolvedConfig.marketplace) {\n config.marketplace = resolvedConfig.marketplace;\n }\n\n const existingProjectConfig = await loadProjectSourceConfig(projectDir);\n if (existingProjectConfig?.author) {\n config.author = existingProjectConfig.author;\n }\n if (existingProjectConfig?.agentsSource) {\n config.agentsSource = existingProjectConfig.agentsSource;\n }\n\n await ensureDir(path.join(projectDir, CLAUDE_SRC_DIR));\n\n // JSON.parse(JSON.stringify(x)) removes undefined values\n const cleaned = JSON.parse(JSON.stringify(config));\n const body = JSON.stringify(cleaned, null, 2);\n const content = `export default ${body};\\n`;\n\n await writeFile(tsConfigPath, content);\n\n return { configPath: tsConfigPath, created: true };\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Checks whether the agents directory contains any agent subdirectories (not just _templates). */\nasync function hasAgentPartialDirs(agentsDir: string): Promise<boolean> {\n const subdirs = await listDirectories(agentsDir);\n const templatesBasename = path.basename(DIRS.templates);\n return subdirs.some((dir) => dir !== templatesBasename);\n}\n","import path from \"path\";\nimport { readdir } from \"fs/promises\";\nimport { directoryExists, listDirectories, remove } from \"../../utils/fs.js\";\nimport { claudePluginUninstall, isClaudeCLIAvailable } from \"../../utils/exec.js\";\nimport { listPluginNames, getProjectPluginsDir } from \"../plugins/index.js\";\nimport { readForkedFromMetadata } from \"../skills/index.js\";\nimport { loadProjectConfigFromDir } from \"../configuration/project-config.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport { CLAUDE_DIR, CLAUDE_SRC_DIR } from \"../../consts.js\";\nimport type { ProjectConfig } from \"../../types/index.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type UninstallTarget = {\n hasPlugins: boolean;\n pluginNames: string[];\n /** Plugin names filtered to only those installed by this CLI (matched against config skills) */\n cliPluginNames: string[];\n hasLocalSkills: boolean;\n hasLocalAgents: boolean;\n hasClaudeDir: boolean;\n hasClaudeSrcDir: boolean;\n pluginsDir: string;\n skillsDir: string;\n agentsDir: string;\n claudeDir: string;\n claudeSrcDir: string;\n /** Resolved project source config from .claude-src/config.ts */\n config: Partial<ProjectConfig> | null;\n /** Agent names from the generated config (e.g., [\"web-developer\"]) */\n configuredAgents: string[];\n};\n\nexport type SkillRemovalResult = {\n removedCount: number;\n skippedCount: number;\n removedNames: string[];\n skippedNames: string[];\n /** Whether the skills directory was cleaned up (empty after removal) */\n dirCleaned: boolean;\n};\n\nexport type AgentRemovalResult = {\n removedCount: number;\n removedNames: string[];\n /** Whether the agents directory was cleaned up (empty after removal) */\n dirCleaned: boolean;\n};\n\nexport type UninstallPluginsResult = {\n uninstalledNames: string[];\n totalUninstalled: number;\n};\n\nexport type CleanupResult = {\n claudeDirRemoved: boolean;\n claudeSrcDirRemoved: boolean;\n /** Whether .claude/ still exists with user content after cleanup */\n claudeDirKept: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// detectUninstallTarget\n// ---------------------------------------------------------------------------\n\nfunction collectConfiguredAgents(config: Partial<ProjectConfig> | null): string[] {\n if (!config?.agents) return [];\n return config.agents.map((a) => a.name);\n}\n\nfunction getCliInstalledPluginKeys(config: Partial<ProjectConfig> | null): Set<string> {\n if (!config?.skills) return new Set();\n return new Set(config.skills.map((skill) => `${skill.id}@${skill.source}`));\n}\n\n/**\n * Detects what's installed in a project directory for uninstallation.\n *\n * Checks for plugins, local skills, agents, config directories, and\n * resolves which plugins were installed by this CLI.\n */\nexport async function detectUninstallTarget(projectDir: string): Promise<UninstallTarget> {\n const pluginsDir = getProjectPluginsDir(projectDir);\n const skillsDir = path.join(projectDir, CLAUDE_DIR, \"skills\");\n const agentsDir = path.join(projectDir, CLAUDE_DIR, \"agents\");\n const claudeDir = path.join(projectDir, CLAUDE_DIR);\n const claudeSrcDir = path.join(projectDir, CLAUDE_SRC_DIR);\n\n const [hasLocalSkills, hasLocalAgents, hasClaudeDir, hasClaudeSrcDir, config] = await Promise.all(\n [\n directoryExists(skillsDir),\n directoryExists(agentsDir),\n directoryExists(claudeDir),\n directoryExists(claudeSrcDir),\n loadProjectConfigFromDir(projectDir).then((result) => result?.config ?? null),\n ],\n );\n\n let pluginNames: string[] = [];\n try {\n pluginNames = await listPluginNames(projectDir);\n } catch {\n // Best-effort: plugin detection may fail\n }\n\n const configuredAgents = collectConfiguredAgents(config);\n const cliInstalledKeys = getCliInstalledPluginKeys(config);\n const cliPluginNames = pluginNames.filter((name) => cliInstalledKeys.has(name));\n\n return {\n hasPlugins: cliPluginNames.length > 0,\n pluginNames,\n cliPluginNames,\n hasLocalSkills,\n hasLocalAgents,\n hasClaudeDir,\n hasClaudeSrcDir,\n pluginsDir,\n skillsDir,\n agentsDir,\n claudeDir,\n claudeSrcDir,\n config,\n configuredAgents,\n };\n}\n\n// ---------------------------------------------------------------------------\n// removeMatchingSkills\n// ---------------------------------------------------------------------------\n\nfunction shouldRemoveSkill(forkedFrom: { source?: string } | null): boolean {\n return forkedFrom !== null;\n}\n\n/**\n * Removes local skills that were installed by the CLI (have forked-from metadata).\n *\n * Scans the skills directory, checks each skill for CLI-installed metadata,\n * and removes matching skills. User-created skills (without metadata) are preserved.\n *\n * @param onRemoved - Called for each removed skill directory name (for logging)\n * @param onSkipped - Called for each skipped skill directory name (for logging)\n */\nexport async function removeMatchingSkills(\n target: Pick<UninstallTarget, \"hasLocalSkills\" | \"skillsDir\">,\n onRemoved?: (dirName: string) => void,\n onSkipped?: (dirName: string) => void,\n): Promise<SkillRemovalResult> {\n if (!target.hasLocalSkills) {\n return {\n removedCount: 0,\n skippedCount: 0,\n removedNames: [],\n skippedNames: [],\n dirCleaned: false,\n };\n }\n\n const skillDirNames = await listDirectories(target.skillsDir);\n const removedNames: string[] = [];\n const skippedNames: string[] = [];\n\n for (const skillDirName of skillDirNames) {\n const skillDir = path.join(target.skillsDir, skillDirName);\n const forkedFrom = await readForkedFromMetadata(skillDir);\n\n if (shouldRemoveSkill(forkedFrom)) {\n await remove(skillDir);\n removedNames.push(skillDirName);\n onRemoved?.(skillDirName);\n } else {\n skippedNames.push(skillDirName);\n onSkipped?.(skillDirName);\n }\n }\n\n let dirCleaned = false;\n if (skippedNames.length === 0 && (await directoryExists(target.skillsDir))) {\n if (await isDirectoryEmpty(target.skillsDir)) {\n await remove(target.skillsDir);\n dirCleaned = true;\n }\n }\n\n return {\n removedCount: removedNames.length,\n skippedCount: skippedNames.length,\n removedNames,\n skippedNames,\n dirCleaned,\n };\n}\n\n// ---------------------------------------------------------------------------\n// removeMatchingAgents\n// ---------------------------------------------------------------------------\n\n/**\n * Removes compiled agent .md files that match configured agent names.\n *\n * Only removes agents that are listed in the project config (CLI-compiled).\n * Cleans up the agents directory if empty after removal.\n *\n * @param onRemoved - Called for each removed agent name (for logging)\n */\nexport async function removeMatchingAgents(\n target: Pick<UninstallTarget, \"hasLocalAgents\" | \"agentsDir\" | \"configuredAgents\">,\n onRemoved?: (agentName: string) => void,\n): Promise<AgentRemovalResult> {\n if (!target.hasLocalAgents) {\n return { removedCount: 0, removedNames: [], dirCleaned: false };\n }\n\n if (target.configuredAgents.length === 0) {\n return { removedCount: 0, removedNames: [], dirCleaned: false };\n }\n\n const agentFiles = await listAgentFiles(target.agentsDir);\n const removedNames: string[] = [];\n\n for (const agentFile of agentFiles) {\n const agentName = agentFile.replace(/\\.md$/, \"\");\n if (!target.configuredAgents.includes(agentName)) continue;\n\n await remove(path.join(target.agentsDir, agentFile));\n removedNames.push(agentName);\n onRemoved?.(agentName);\n }\n\n let dirCleaned = false;\n if (await directoryExists(target.agentsDir)) {\n if (await isDirectoryEmpty(target.agentsDir)) {\n await remove(target.agentsDir);\n dirCleaned = true;\n }\n }\n\n return {\n removedCount: removedNames.length,\n removedNames,\n dirCleaned,\n };\n}\n\n// ---------------------------------------------------------------------------\n// uninstallPlugins\n// ---------------------------------------------------------------------------\n\n/**\n * Uninstalls CLI-managed plugins by removing them from the Claude CLI\n * and deleting their local directories.\n *\n * Derives scope from per-skill config when available; falls back to project-level.\n *\n * @param onUninstalled - Called for each successfully uninstalled plugin name (for logging)\n */\nexport async function uninstallPlugins(\n target: Pick<UninstallTarget, \"hasPlugins\" | \"cliPluginNames\" | \"pluginsDir\" | \"config\">,\n projectDir: string,\n onUninstalled?: (pluginName: string) => void,\n): Promise<UninstallPluginsResult> {\n if (!target.hasPlugins) {\n return { uninstalledNames: [], totalUninstalled: 0 };\n }\n\n const cliAvailable = await isClaudeCLIAvailable();\n const uninstalledNames: string[] = [];\n\n for (const pluginName of target.cliPluginNames) {\n if (cliAvailable) {\n try {\n // Derive scope from per-skill config; fall back to project-level heuristic\n const skillId = pluginName.split(\"@\")[0];\n const skillConfig = target.config?.skills?.find((s) => s.id === skillId);\n const pluginScope = skillConfig?.scope === \"global\" ? \"user\" : \"project\";\n await claudePluginUninstall(pluginName, pluginScope, projectDir);\n } catch {\n // Best-effort: plugin may not be registered with Claude CLI\n }\n }\n\n const pluginPath = path.join(target.pluginsDir, pluginName);\n await remove(pluginPath);\n uninstalledNames.push(pluginName);\n onUninstalled?.(pluginName);\n }\n\n return {\n uninstalledNames,\n totalUninstalled: uninstalledNames.length,\n };\n}\n\n// ---------------------------------------------------------------------------\n// cleanupEmptyDirs\n// ---------------------------------------------------------------------------\n\n/**\n * Removes empty .claude/ and .claude-src/ directories after uninstall.\n *\n * Only removes .claude-src/ when `removeAll` is true.\n * Only removes .claude/ when it's completely empty.\n */\nexport async function cleanupEmptyDirs(\n target: Pick<UninstallTarget, \"hasClaudeDir\" | \"hasClaudeSrcDir\" | \"claudeDir\" | \"claudeSrcDir\">,\n removeAll: boolean,\n): Promise<CleanupResult> {\n let claudeSrcDirRemoved = false;\n if (removeAll && target.hasClaudeSrcDir) {\n await remove(target.claudeSrcDir);\n claudeSrcDirRemoved = true;\n }\n\n let claudeDirRemoved = false;\n let claudeDirKept = false;\n if (target.hasClaudeDir && (await directoryExists(target.claudeDir))) {\n if (await isDirectoryEmpty(target.claudeDir)) {\n await remove(target.claudeDir);\n claudeDirRemoved = true;\n } else {\n claudeDirKept = true;\n }\n }\n\n return { claudeDirRemoved, claudeSrcDirRemoved, claudeDirKept };\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nasync function isDirectoryEmpty(dirPath: string): Promise<boolean> {\n try {\n const allEntries = await readdir(dirPath);\n return allEntries.length === 0;\n } catch {\n return true;\n }\n}\n\nasync function listAgentFiles(agentsDir: string): Promise<string[]> {\n try {\n return (await readdir(agentsDir)).filter((f) => f.endsWith(\".md\"));\n } catch {\n return [];\n }\n}\n","import path from \"path\";\n\nimport { DEFAULT_SKILLS_SUBDIR, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../../consts.js\";\nimport type { SourceEntry } from \"../../types/config.js\";\nimport type { CategoryPath, ResolvedSkill, SkillSlug } from \"../../types/index.js\";\nimport { copy, ensureDir, fileExists, listDirectories, readFile } from \"../../utils/fs.js\";\nimport { fetchFromSource, parseFrontmatter } from \"../loading/index.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A skill with source provenance info, used for search results and imports. */\nexport type SourcedSkill = ResolvedSkill & {\n sourceName: string;\n sourceUrl?: string;\n};\n\nexport type FilterSkillsOptions = {\n query: string;\n category?: string;\n};\n\nexport type CopySearchedSkillResult = {\n id: string;\n copied: boolean;\n /** Reason when `copied` is false */\n reason?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Fetching\n// ---------------------------------------------------------------------------\n\n/**\n * Fetches skills from an external (non-primary) source entry.\n *\n * Discovers SKILL.md files in the source's skills directory, parses\n * frontmatter, and returns typed SourcedSkill entries.\n * Returns an empty array when the source is unavailable or has no skills.\n */\nexport async function fetchSkillsFromExternalSource(\n source: SourceEntry,\n forceRefresh: boolean,\n): Promise<SourcedSkill[]> {\n try {\n const result = await fetchFromSource(source.url, { forceRefresh });\n const skillsDir = path.join(result.path, DEFAULT_SKILLS_SUBDIR);\n\n if (!(await fileExists(skillsDir))) {\n return [];\n }\n\n const skillDirs = await listDirectories(skillsDir);\n const skills: SourcedSkill[] = [];\n\n for (const skillDir of skillDirs) {\n const skillMdPath = path.join(skillsDir, skillDir, STANDARD_FILES.SKILL_MD);\n if (!(await fileExists(skillMdPath))) continue;\n\n const content = await readFile(skillMdPath);\n const frontmatter = parseFrontmatter(content, skillMdPath);\n if (!frontmatter) continue;\n\n skills.push({\n id: frontmatter.name,\n description: frontmatter.description,\n // Boundary cast: directory name used as slug for third-party source skill\n slug: skillDir as SkillSlug,\n displayName: skillDir,\n // Boundary cast: external source skills have no real category; \"imported\" is a display-only placeholder\n category: \"imported\" as CategoryPath,\n author: `@${source.name}`,\n conflictsWith: [],\n isRecommended: false,\n requires: [],\n alternatives: [],\n discourages: [],\n compatibleWith: [],\n sourceName: source.name,\n sourceUrl: source.url,\n path: path.join(skillsDir, skillDir),\n });\n }\n\n return skills;\n } catch {\n // Source unavailable, return empty\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Filtering\n// ---------------------------------------------------------------------------\n\nfunction matchesQuery(skill: ResolvedSkill, query: string): boolean {\n const lowerQuery = query.toLowerCase();\n\n if (skill.id.toLowerCase().includes(lowerQuery)) return true;\n if (skill.displayName.toLowerCase().includes(lowerQuery)) return true;\n if (skill.slug.toLowerCase().includes(lowerQuery)) return true;\n if (skill.description.toLowerCase().includes(lowerQuery)) return true;\n if (skill.category.toLowerCase().includes(lowerQuery)) return true;\n\n return false;\n}\n\nfunction matchesCategory(skill: ResolvedSkill, category: string): boolean {\n const lowerCategory = category.toLowerCase();\n return skill.category.toLowerCase().includes(lowerCategory);\n}\n\n/**\n * Filters skills by text query and optional category.\n *\n * Matches against id, displayName, slug, description, and category fields.\n */\nexport function filterSkillsByQuery(\n skills: ResolvedSkill[],\n options: FilterSkillsOptions,\n): ResolvedSkill[] {\n let results = skills.filter((skill) => matchesQuery(skill, options.query));\n\n if (options.category) {\n results = results.filter((skill) => matchesCategory(skill, options.category!));\n }\n\n return results;\n}\n\n// ---------------------------------------------------------------------------\n// Conversion\n// ---------------------------------------------------------------------------\n\n/** Converts a ResolvedSkill to a SourcedSkill by attaching source provenance. */\nexport function toSourcedSkill(\n skill: ResolvedSkill,\n sourceName: string,\n sourceUrl?: string,\n): SourcedSkill {\n return {\n ...skill,\n sourceName,\n sourceUrl,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Copy\n// ---------------------------------------------------------------------------\n\n/**\n * Copies selected searched skills to the project's local skills directory.\n *\n * Each skill must have a `path` property pointing to its source directory.\n * Skills without a path are skipped and reported in the result.\n */\nexport async function copySearchedSkillsToLocal(\n skills: SourcedSkill[],\n projectDir: string,\n): Promise<CopySearchedSkillResult[]> {\n const destDir = path.join(projectDir, LOCAL_SKILLS_PATH);\n const results: CopySearchedSkillResult[] = [];\n\n for (const skill of skills) {\n if (skill.path) {\n const destPath = path.join(destDir, skill.id);\n await ensureDir(path.dirname(destPath));\n await copy(skill.path, destPath);\n results.push({ id: skill.id, copied: true });\n } else {\n results.push({ id: skill.id, copied: false, reason: \"No source path available\" });\n }\n }\n\n return results;\n}\n","import { spawn } from \"child_process\";\nimport matter from \"gray-matter\";\nimport path from \"path\";\n\nimport { CLAUDE_DIR } from \"../../consts.js\";\nimport { getAgentDefinitions } from \"../agents/index.js\";\nimport { fileExists, readFile } from \"../../utils/fs.js\";\n\nconst META_AGENT_NAME = \"agent-summoner\";\n\nexport type NewAgentInput = {\n description: string;\n prompt: string;\n model?: string;\n tools?: string[];\n};\n\nexport type LoadMetaAgentOptions = {\n projectDir: string;\n source: string;\n forceRefresh: boolean;\n};\n\nexport type InvokeMetaAgentOptions = {\n agentDef: NewAgentInput;\n prompt: string;\n nonInteractive: boolean;\n};\n\n/**\n * Parses a compiled agent markdown file to extract the agent definition.\n *\n * Reads YAML frontmatter for description/model/tools and the body as the prompt.\n */\nexport function parseCompiledAgent(content: string): NewAgentInput {\n const { data: frontmatter, content: body } = matter(content);\n const tools =\n typeof frontmatter.tools === \"string\"\n ? frontmatter.tools.split(\",\").map((t: string) => t.trim())\n : frontmatter.tools;\n\n return {\n description: frontmatter.description || \"Creates new agents\",\n prompt: body.trim(),\n model: frontmatter.model,\n tools,\n };\n}\n\n/**\n * Loads the meta-agent (agent-summoner) from either a compiled local agent\n * or a remote source. Parses the compiled agent markdown.\n *\n * @throws {Error} If the meta-agent cannot be found locally or remotely.\n */\nexport async function loadMetaAgent(options: LoadMetaAgentOptions): Promise<NewAgentInput> {\n const { projectDir, source, forceRefresh } = options;\n const compiledFileName = `${META_AGENT_NAME}.md`;\n\n // Check for compiled agent in the current project\n const localAgentPath = path.join(projectDir, CLAUDE_DIR, \"agents\", compiledFileName);\n if (await fileExists(localAgentPath)) {\n return parseCompiledAgent(await readFile(localAgentPath));\n }\n\n // Fall back to remote source (may not have agents)\n try {\n const agentPaths = await getAgentDefinitions(source, { forceRefresh, projectDir });\n const remoteAgentPath = path.join(\n agentPaths.sourcePath,\n CLAUDE_DIR,\n \"agents\",\n compiledFileName,\n );\n if (await fileExists(remoteAgentPath)) {\n return parseCompiledAgent(await readFile(remoteAgentPath));\n }\n } catch {\n // Source does not contain agents — fall through to error\n }\n\n throw new Error(\n `Agent '${META_AGENT_NAME}' not found.\\n\\n` + `Run 'compile' first to generate agents.`,\n );\n}\n\n/**\n * Constructs the prompt for the meta-agent based on user input.\n */\nexport function buildAgentPrompt(agentName: string, purpose: string, outputDir: string): string {\n return `Create a new Claude Code agent named \"${agentName}\" in the directory \"${outputDir}\".\n\nAgent Purpose: ${purpose}\n\nRequirements:\n1. Create the agent directory structure at ${outputDir}/${agentName}/\n2. Create metadata.yaml with appropriate configuration\n3. Create intro.md with the agent's role and context\n4. Create workflow.md with the agent's operational process\n5. Optionally create examples.md if relevant examples would help\n6. Optionally create critical-requirements.md for important rules\n7. Include \\`custom: true\\` in the metadata.yaml configuration\n\nFollow the existing agent patterns in the codebase. Keep the agent focused and practical.`;\n}\n\n/**\n * Spawns the Claude CLI to execute the meta-agent with the constructed prompt.\n *\n * Uses `stdio: \"inherit\"` so the CLI output streams directly to the terminal.\n *\n * @throws {Error} If the Claude CLI fails to spawn or exits with a non-zero code.\n */\nexport async function invokeMetaAgent(options: InvokeMetaAgentOptions): Promise<void> {\n const { agentDef, prompt, nonInteractive } = options;\n\n const agentsJson = JSON.stringify({\n [META_AGENT_NAME]: {\n description: agentDef.description,\n prompt: agentDef.prompt,\n model: agentDef.model,\n tools: agentDef.tools,\n },\n });\n\n const args = [\"--agents\", agentsJson, \"--agent\", META_AGENT_NAME];\n\n if (nonInteractive) {\n args.push(\"-p\", prompt);\n } else {\n args.push(\"--prompt\", prompt);\n }\n\n return new Promise((resolve, reject) => {\n const child = spawn(\"claude\", args, {\n stdio: \"inherit\",\n });\n\n child.on(\"error\", (error) => {\n reject(new Error(`Failed to spawn claude CLI: ${error.message}`));\n });\n\n child.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`Claude CLI exited with code ${code}`));\n }\n });\n });\n}\n","import { claudePluginInstall, claudePluginUninstall } from \"../../utils/exec.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport type { SkillId } from \"../../types/index.js\";\n\nexport type PluginScopeMigrationResult = {\n migrated: SkillId[];\n failed: Array<{ id: SkillId; error: string }>;\n};\n\n/**\n * Migrates plugin skills between scopes by uninstalling from the old scope\n * and reinstalling to the new scope via the Claude CLI.\n *\n * Only processes plugin skills (source !== \"local\"). Local skills are\n * handled separately via `migrateLocalSkillScope`.\n */\nexport async function migratePluginSkillScopes(\n scopeChanges: Map<SkillId, { from: \"project\" | \"global\"; to: \"project\" | \"global\" }>,\n skills: Array<{ id: SkillId; source: string }>,\n marketplace: string,\n projectDir: string,\n): Promise<PluginScopeMigrationResult> {\n const migrated: SkillId[] = [];\n const failed: PluginScopeMigrationResult[\"failed\"] = [];\n\n for (const [skillId, change] of scopeChanges) {\n const skillConfig = skills.find((s) => s.id === skillId);\n if (!skillConfig || skillConfig.source === \"local\") {\n continue;\n }\n\n const oldPluginScope = change.from === \"global\" ? \"user\" : \"project\";\n const newPluginScope = change.to === \"global\" ? \"user\" : \"project\";\n const pluginRef = `${skillId}@${marketplace}`;\n\n try {\n await claudePluginUninstall(skillId, oldPluginScope, projectDir);\n await claudePluginInstall(pluginRef, newPluginScope, projectDir);\n migrated.push(skillId);\n } catch (error) {\n failed.push({ id: skillId, error: getErrorMessage(error) });\n }\n }\n\n return { migrated, failed };\n}\n","// Operations — composable building blocks for CLI commands.\n// Each operation wraps lower-level lib functions into a single typed call.\n\nexport { detectBothInstallations, type BothInstallations } from \"./detect-both-installations.js\";\nexport { loadSource, type LoadSourceOptions, type LoadedSource } from \"./load-source.js\";\nexport { getDashboardData, type DashboardData } from \"./get-dashboard-data.js\";\nexport { detectProject, type DetectedProject } from \"./detect-project.js\";\nexport { loadAgentDefs, type AgentDefs } from \"./load-agent-defs.js\";\nexport { copyLocalSkills, type SkillCopyResult } from \"./copy-local-skills.js\";\nexport { installPluginSkills, type PluginInstallResult } from \"./install-plugin-skills.js\";\nexport { uninstallPluginSkills, type PluginUninstallResult } from \"./uninstall-plugin-skills.js\";\nexport {\n compareSkillsWithSource,\n buildSourceSkillsMap,\n type SkillComparisonResults,\n} from \"./compare-skills.js\";\nexport { ensureMarketplace, type MarketplaceResult } from \"./ensure-marketplace.js\";\nexport {\n writeProjectConfig,\n type ConfigWriteOptions,\n type ConfigWriteResult,\n} from \"./write-project-config.js\";\nexport {\n compileAgents,\n type CompileAgentsOptions,\n type CompilationResult,\n} from \"./compile-agents.js\";\nexport { detectConfigChanges, type ConfigChanges } from \"./detect-config-changes.js\";\nexport {\n executeInstallation,\n type ExecuteInstallationOptions,\n type ExecuteInstallationResult,\n} from \"./execute-installation.js\";\nexport {\n recompileProject,\n type RecompileProjectOptions,\n type RecompileProjectResult,\n} from \"./recompile-project.js\";\nexport {\n updateLocalSkills,\n type SkillUpdateResult,\n type UpdateLocalSkillsResult,\n type UpdateLocalSkillsOptions,\n} from \"./update-local-skills.js\";\nexport {\n discoverInstalledSkills,\n loadSkillsFromDir,\n discoverLocalProjectSkills,\n mergeSkills,\n type DiscoveredSkills,\n} from \"./discover-skills.js\";\nexport {\n collectScopedSkillDirs,\n type ScopedSkillDir,\n type ScopedSkillDirsResult,\n} from \"./collect-scoped-skill-dirs.js\";\nexport { findSkillMatch, type SkillMatchResult } from \"./find-skill-match.js\";\nexport {\n generateSkillDiff,\n formatColoredDiff,\n type SkillDiffResult,\n} from \"./generate-skill-diff.js\";\nexport {\n resolveSkillInfo,\n type ResolveSkillInfoOptions,\n type ResolvedSkillInfo,\n type SkillInfoResult,\n} from \"./resolve-skill-info.js\";\nexport {\n ejectAgentPartials,\n ejectSkills,\n ensureMinimalConfig,\n type EjectAgentPartialsOptions,\n type EjectAgentPartialsResult,\n type EjectSkillsOptions,\n type EjectSkillsResult,\n type EnsureMinimalConfigOptions,\n type EnsureMinimalConfigResult,\n} from \"./eject-project.js\";\nexport {\n detectUninstallTarget,\n removeMatchingSkills,\n removeMatchingAgents,\n uninstallPlugins,\n cleanupEmptyDirs,\n type UninstallTarget,\n type SkillRemovalResult,\n type AgentRemovalResult,\n type UninstallPluginsResult,\n type CleanupResult,\n} from \"./uninstall-project.js\";\nexport {\n fetchSkillsFromExternalSource,\n filterSkillsByQuery,\n toSourcedSkill,\n copySearchedSkillsToLocal,\n type SourcedSkill,\n type FilterSkillsOptions,\n type CopySearchedSkillResult,\n} from \"./search-skills.js\";\nexport {\n parseGitHubSource,\n fetchSkillSource,\n discoverValidSkills,\n importSkillFromSource,\n type ImportedForkedFromMetadata,\n type ParsedGitHubSource,\n type FetchSourceOptions,\n type FetchedSource,\n type ImportSkillOptions,\n type ImportSkillResult,\n} from \"./import-skill.js\";\nexport {\n parseCompiledAgent,\n loadMetaAgent,\n buildAgentPrompt,\n invokeMetaAgent,\n type NewAgentInput,\n type LoadMetaAgentOptions,\n type InvokeMetaAgentOptions,\n} from \"./scaffold-agent.js\";\nexport {\n migratePluginSkillScopes,\n type PluginScopeMigrationResult,\n} from \"./migrate-plugin-scope.js\";\nexport {\n validateSkillName,\n toTitleCase,\n generateSkillMd,\n generateMetadataYaml,\n generateSkillCategoriesTs,\n generateSkillRulesTs,\n scaffoldSkillFiles,\n updateSkillRegistryConfig,\n type ScaffoldSkillOptions,\n type ScaffoldSkillResult,\n type RegistryUpdateOptions,\n type RegistryUpdateResult,\n} from \"./scaffold-skill.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,OAAO,QAAQ;AAoBf,eAAsB,wBA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A,EAC9B;AAEA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,QAAQ,MAAM,UAAU,MAAM;AAAA,MAClC,OAAO;AAAA,IACT,CAAC;AAED,UAAM,GAAG,SAAS,CAAC,UAAU;AAC3B,aAAO,IAAI,MAAM,+BAA+B,MAAM,OAAO,EAAE,CAAC;AAAA,IAClE,CAAC;AAED,UAAM,GAAG,SAAS,CAAC,SAAS;AAC1B,UAAI,SAAS,GAAG;AACd,gBAAQ;AAAA,MACV,OAAO;AACL,eAAO,IAAI,MAAM,+BAA+B,IAAI,EAAE,CAAC;AAAA,MACzD;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;;;ACtJA;AAgBA,eAAsB,yBACpB,cACA,QACA,aACA,YACqC;AACrC,QAAM,WAAsB,CAAC;AAC7B,QAAM,SAA+C,CAAC;AAEtD,aAAW,CAAC,SAAS,MAAM,KAAK,cAAc;AAC5C,UAAM,cAAc,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO;AACvD,QAAI,CAAC,eAAe,YAAY,WAAW,SAAS;AAClD;AAAA,IACF;AAEA,UAAM,iBAAiB,OAAO,SAAS,WAAW,SAAS;AAC3D,UAAM,iBAAiB,OAAO,OAAO,WAAW,SAAS;AACzD,UAAM,YAAY,GAAG,OAAO,IAAI,WAAW;AAE3C,QAAI;AACF,YAAM,sBAAsB,SAAS,gBAAgB,UAAU;AAC/D,YAAM,oBAAoB,WAAW,gBAAgB,UAAU;AAC/D,eAAS,KAAK,OAAO;AAAA,IACvB,SAAS,OAAO;AACd,aAAO,KAAK,EAAE,IAAI,SAAS,OAAO,gBAAgB,KAAK,EAAE,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,SAAO,EAAE,UAAU,OAAO;AAC5B;;;AC7CA;","names":["os","os","os","os","os","path","path","os","path","path","os","path","path","os","process","os","styles","chalk","styles","path","path","path","path","path","path","path","path","path","path","path","path"]}
@@ -17,11 +17,11 @@ import {
17
17
  resolveAgents,
18
18
  writeContentHash,
19
19
  writePluginManifest
20
- } from "./chunk-FKXD3EXJ.js";
20
+ } from "./chunk-TMTUTUEV.js";
21
21
  import {
22
22
  loadAllAgents,
23
23
  loadProjectAgents
24
- } from "./chunk-YJ2URWF7.js";
24
+ } from "./chunk-B6MYECV6.js";
25
25
  import {
26
26
  typedEntries,
27
27
  typedKeys
@@ -39,7 +39,7 @@ import {
39
39
  verbose,
40
40
  warn,
41
41
  writeFile
42
- } from "./chunk-WJKD6EGK.js";
42
+ } from "./chunk-NUU3U43A.js";
43
43
  import {
44
44
  CLAUDE_DIR,
45
45
  DIRS,
@@ -114,14 +114,97 @@ async function fetchAgentDefinitionsFromRemote(source, options = {}) {
114
114
  };
115
115
  }
116
116
 
117
+ // src/cli/lib/agents/agent-plugin-compiler.ts
118
+ init_esm_shims();
119
+ import path2 from "path";
120
+ function parseAgentFrontmatter(content, filePath) {
121
+ const raw = extractFrontmatter(content);
122
+ if (!raw) {
123
+ return null;
124
+ }
125
+ const result = agentFrontmatterValidationSchema.safeParse(raw);
126
+ if (!result.success) {
127
+ warn(`Invalid agent frontmatter in ${filePath}: ${formatZodErrors(result.error.issues)}`);
128
+ return null;
129
+ }
130
+ return { name: result.data.name, description: result.data.description };
131
+ }
132
+ async function compileAgentPlugin(options) {
133
+ const { agentPath, outputDir } = options;
134
+ const fileName = path2.basename(agentPath);
135
+ const content = await readFile(agentPath);
136
+ const frontmatter = parseAgentFrontmatter(content, agentPath);
137
+ if (!frontmatter) {
138
+ throw new Error(
139
+ `Agent '${fileName}' has invalid or missing YAML frontmatter. Required fields: 'name' and 'description'. File: ${agentPath}`
140
+ );
141
+ }
142
+ const agentName = frontmatter.name;
143
+ verbose(`Compiling agent plugin: ${agentName} from ${agentPath}`);
144
+ const pluginDir = path2.join(outputDir, `agent-${agentName}`);
145
+ const agentsDir = path2.join(pluginDir, "agents");
146
+ await ensureDir(pluginDir);
147
+ await ensureDir(agentsDir);
148
+ const newHash = computeStringHash(content);
149
+ const { version, contentHash } = await determinePluginVersion(
150
+ newHash,
151
+ pluginDir,
152
+ getPluginManifestPath
153
+ );
154
+ const manifest = generateAgentPluginManifest({
155
+ agentName,
156
+ description: frontmatter.description,
157
+ version
158
+ });
159
+ await writePluginManifest(pluginDir, manifest);
160
+ await writeContentHash(pluginDir, contentHash, getPluginManifestPath);
161
+ verbose(` Wrote plugin.json for ${agentName} (v${version})`);
162
+ await copy(agentPath, path2.join(agentsDir, `${agentName}.md`));
163
+ verbose(` Copied agent ${fileName} -> agents/${agentName}.md`);
164
+ return {
165
+ pluginPath: pluginDir,
166
+ manifest,
167
+ agentName
168
+ };
169
+ }
170
+ async function compileAllAgentPlugins(agentsDir, outputDir) {
171
+ const results = [];
172
+ const agentMdFiles = await glob("*.md", agentsDir);
173
+ for (const agentFile of agentMdFiles) {
174
+ const agentPath = path2.join(agentsDir, agentFile);
175
+ try {
176
+ const result = await compileAgentPlugin({
177
+ agentPath,
178
+ outputDir
179
+ });
180
+ results.push(result);
181
+ log(` [OK] agent-${result.agentName}`);
182
+ } catch (error) {
183
+ const errorMessage = getErrorMessage(error);
184
+ warn(`Failed to compile agent from '${agentFile}': ${errorMessage}`);
185
+ }
186
+ }
187
+ return results;
188
+ }
189
+ function printAgentCompilationSummary(results) {
190
+ log(`
191
+ Compiled ${results.length} agent plugins:`);
192
+ for (const result of results) {
193
+ log(` - agent-${result.agentName} (v${result.manifest.version})`);
194
+ }
195
+ }
196
+
197
+ // src/cli/lib/agents/index.ts
198
+ init_esm_shims();
199
+
117
200
  // src/cli/lib/agents/agent-recompiler.ts
118
201
  init_esm_shims();
119
202
  import os from "os";
120
- import path2 from "path";
203
+ import path3 from "path";
121
204
  async function getExistingAgentNames(pluginDir) {
122
205
  const agentsDir = getPluginAgentsDir(pluginDir);
123
206
  const files = await glob("*.md", agentsDir);
124
- return files.map((f) => path2.basename(f, ".md"));
207
+ return files.map((f) => path3.basename(f, ".md"));
125
208
  }
126
209
  async function resolveAgentNames(params) {
127
210
  const { specifiedAgents, projectConfig, allAgents, outputDir, pluginDir } = params;
@@ -153,7 +236,7 @@ function buildCompileConfig(params) {
153
236
  }
154
237
  }
155
238
  const compileConfig = {
156
- name: projectConfig?.name || path2.basename(pluginDir),
239
+ name: projectConfig?.name || path3.basename(pluginDir),
157
240
  description: projectConfig?.description || "Recompiled plugin",
158
241
  agents: compileAgents
159
242
  };
@@ -161,14 +244,14 @@ function buildCompileConfig(params) {
161
244
  }
162
245
  async function compileAndWriteAgents(params, result) {
163
246
  const { resolvedAgents, agentsDir, sourcePath, engine, installMode, agentScopeMap } = params;
164
- const globalAgentsDir = path2.join(os.homedir(), CLAUDE_DIR, "agents");
247
+ const globalAgentsDir = path3.join(os.homedir(), CLAUDE_DIR, "agents");
165
248
  await ensureDir(globalAgentsDir);
166
249
  for (const [agentName, agent] of typedEntries(resolvedAgents)) {
167
250
  try {
168
251
  const output = await compileAgentForPlugin(agentName, agent, sourcePath, engine, installMode);
169
252
  const scope = agentScopeMap?.get(agentName) ?? "project";
170
253
  const targetDir = scope === "global" ? globalAgentsDir : agentsDir;
171
- await writeFile(path2.join(targetDir, `${agentName}.md`), output);
254
+ await writeFile(path3.join(targetDir, `${agentName}.md`), output);
172
255
  result.compiled.push(agentName);
173
256
  verbose(` Recompiled: ${agentName} (${scope} -> ${targetDir})`);
174
257
  } catch (error) {
@@ -236,93 +319,10 @@ async function recompileAgents(options) {
236
319
  return result;
237
320
  }
238
321
 
239
- // src/cli/lib/agents/agent-plugin-compiler.ts
240
- init_esm_shims();
241
- import path3 from "path";
242
- function parseAgentFrontmatter(content, filePath) {
243
- const raw = extractFrontmatter(content);
244
- if (!raw) {
245
- return null;
246
- }
247
- const result = agentFrontmatterValidationSchema.safeParse(raw);
248
- if (!result.success) {
249
- warn(`Invalid agent frontmatter in ${filePath}: ${formatZodErrors(result.error.issues)}`);
250
- return null;
251
- }
252
- return { name: result.data.name, description: result.data.description };
253
- }
254
- async function compileAgentPlugin(options) {
255
- const { agentPath, outputDir } = options;
256
- const fileName = path3.basename(agentPath);
257
- const content = await readFile(agentPath);
258
- const frontmatter = parseAgentFrontmatter(content, agentPath);
259
- if (!frontmatter) {
260
- throw new Error(
261
- `Agent '${fileName}' has invalid or missing YAML frontmatter. Required fields: 'name' and 'description'. File: ${agentPath}`
262
- );
263
- }
264
- const agentName = frontmatter.name;
265
- verbose(`Compiling agent plugin: ${agentName} from ${agentPath}`);
266
- const pluginDir = path3.join(outputDir, `agent-${agentName}`);
267
- const agentsDir = path3.join(pluginDir, "agents");
268
- await ensureDir(pluginDir);
269
- await ensureDir(agentsDir);
270
- const newHash = computeStringHash(content);
271
- const { version, contentHash } = await determinePluginVersion(
272
- newHash,
273
- pluginDir,
274
- getPluginManifestPath
275
- );
276
- const manifest = generateAgentPluginManifest({
277
- agentName,
278
- description: frontmatter.description,
279
- version
280
- });
281
- await writePluginManifest(pluginDir, manifest);
282
- await writeContentHash(pluginDir, contentHash, getPluginManifestPath);
283
- verbose(` Wrote plugin.json for ${agentName} (v${version})`);
284
- await copy(agentPath, path3.join(agentsDir, `${agentName}.md`));
285
- verbose(` Copied agent ${fileName} -> agents/${agentName}.md`);
286
- return {
287
- pluginPath: pluginDir,
288
- manifest,
289
- agentName
290
- };
291
- }
292
- async function compileAllAgentPlugins(agentsDir, outputDir) {
293
- const results = [];
294
- const agentMdFiles = await glob("*.md", agentsDir);
295
- for (const agentFile of agentMdFiles) {
296
- const agentPath = path3.join(agentsDir, agentFile);
297
- try {
298
- const result = await compileAgentPlugin({
299
- agentPath,
300
- outputDir
301
- });
302
- results.push(result);
303
- log(` [OK] agent-${result.agentName}`);
304
- } catch (error) {
305
- const errorMessage = getErrorMessage(error);
306
- warn(`Failed to compile agent from '${agentFile}': ${errorMessage}`);
307
- }
308
- }
309
- return results;
310
- }
311
- function printAgentCompilationSummary(results) {
312
- log(`
313
- Compiled ${results.length} agent plugins:`);
314
- for (const result of results) {
315
- log(` - agent-${result.agentName} (v${result.manifest.version})`);
316
- }
317
- }
318
-
319
- // src/cli/lib/agents/index.ts
320
- init_esm_shims();
321
-
322
322
  export {
323
323
  getAgentDefinitions,
324
324
  recompileAgents,
325
325
  compileAllAgentPlugins,
326
326
  printAgentCompilationSummary
327
327
  };
328
- //# sourceMappingURL=chunk-CYPCJ536.js.map
328
+ //# sourceMappingURL=chunk-FBZR46GC.js.map