@agents-inc/cli 0.85.0 → 0.87.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 (121) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-6VGBO6SZ.js → chunk-5M6Q5UQO.js} +2 -2
  3. package/dist/chunk-5UJJQFET.js +564 -0
  4. package/dist/chunk-5UJJQFET.js.map +1 -0
  5. package/dist/{chunk-TXW257CU.js → chunk-7FFNNDJQ.js} +181 -202
  6. package/dist/chunk-7FFNNDJQ.js.map +1 -0
  7. package/dist/{chunk-YJ2URWF7.js → chunk-B6MYECV6.js} +2 -2
  8. package/dist/{chunk-G2MINRWX.js → chunk-C5IYJ42F.js} +2 -2
  9. package/dist/{chunk-7UZUDHP7.js → chunk-CXWBVBDM.js} +2 -2
  10. package/dist/{chunk-CYPCJ536.js → chunk-FBZR46GC.js} +92 -92
  11. package/dist/chunk-FBZR46GC.js.map +1 -0
  12. package/dist/{chunk-LTFGEVTM.js → chunk-HH3AWXF4.js} +3 -3
  13. package/dist/{chunk-2XVLQDNI.js → chunk-HSLVCKVQ.js} +3 -3
  14. package/dist/{chunk-TAQGYJIS.js → chunk-HZ2IBXVQ.js} +3 -3
  15. package/dist/{chunk-LN76TJJP.js → chunk-HZQOFFKA.js} +10 -10
  16. package/dist/{chunk-W7LHI54P.js → chunk-I44YG6VI.js} +2 -2
  17. package/dist/{chunk-FT46LN7K.js → chunk-I5AZKNNL.js} +7 -8
  18. package/dist/chunk-I5AZKNNL.js.map +1 -0
  19. package/dist/chunk-J6PI73YV.js +68 -0
  20. package/dist/chunk-J6PI73YV.js.map +1 -0
  21. package/dist/{chunk-L7COG2EX.js → chunk-LZ7XQ3IU.js} +2 -2
  22. package/dist/{chunk-LMR7VAP3.js → chunk-MMTMXLI4.js} +2 -2
  23. package/dist/chunk-N6A7A4RA.js +16 -0
  24. package/dist/chunk-N6A7A4RA.js.map +1 -0
  25. package/dist/{chunk-WJKD6EGK.js → chunk-NUU3U43A.js} +5 -6
  26. package/dist/chunk-NUU3U43A.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-ZGD7PLLC.js → chunk-ZOWRO7UQ.js} +3 -3
  33. package/dist/commands/build/marketplace.js +3 -3
  34. package/dist/commands/build/plugins.js +5 -5
  35. package/dist/commands/build/stack.js +5 -5
  36. package/dist/commands/compile.js +77 -171
  37. package/dist/commands/compile.js.map +1 -1
  38. package/dist/commands/config/index.js +5 -5
  39. package/dist/commands/config/path.js +4 -4
  40. package/dist/commands/config/show.js +5 -5
  41. package/dist/commands/diff.js +161 -167
  42. package/dist/commands/diff.js.map +1 -1
  43. package/dist/commands/doctor.js +68 -83
  44. package/dist/commands/doctor.js.map +1 -1
  45. package/dist/commands/edit.js +275 -209
  46. package/dist/commands/edit.js.map +1 -1
  47. package/dist/commands/eject.js +206 -124
  48. package/dist/commands/eject.js.map +1 -1
  49. package/dist/commands/import/skill.js +175 -144
  50. package/dist/commands/import/skill.js.map +1 -1
  51. package/dist/commands/info.js +58 -102
  52. package/dist/commands/info.js.map +1 -1
  53. package/dist/commands/init.js +19 -16
  54. package/dist/commands/list.js +4 -4
  55. package/dist/commands/new/agent.js +124 -102
  56. package/dist/commands/new/agent.js.map +1 -1
  57. package/dist/commands/new/marketplace.js +6 -6
  58. package/dist/commands/new/marketplace.js.map +1 -1
  59. package/dist/commands/new/skill.js +328 -15
  60. package/dist/commands/new/skill.js.map +1 -1
  61. package/dist/commands/outdated.js +16 -24
  62. package/dist/commands/outdated.js.map +1 -1
  63. package/dist/commands/search.js +166 -132
  64. package/dist/commands/search.js.map +1 -1
  65. package/dist/commands/uninstall.js +269 -189
  66. package/dist/commands/uninstall.js.map +1 -1
  67. package/dist/commands/update.js +238 -219
  68. package/dist/commands/update.js.map +1 -1
  69. package/dist/commands/validate.js +4 -4
  70. package/dist/components/skill-search/skill-search.js +2 -1
  71. package/dist/components/wizard/category-grid.test.js +4 -4
  72. package/dist/components/wizard/domain-selection.js +5 -5
  73. package/dist/components/wizard/help-modal.js +5 -5
  74. package/dist/components/wizard/source-grid.test.js +4 -4
  75. package/dist/components/wizard/stack-selection.js +5 -5
  76. package/dist/components/wizard/step-agents.js +5 -5
  77. package/dist/components/wizard/step-agents.test.js +5 -5
  78. package/dist/components/wizard/step-build.js +5 -5
  79. package/dist/components/wizard/step-build.test.js +5 -5
  80. package/dist/components/wizard/step-confirm.test.js +4 -4
  81. package/dist/components/wizard/step-settings.js +4 -4
  82. package/dist/components/wizard/step-settings.test.js +7 -7
  83. package/dist/components/wizard/step-sources.js +5 -5
  84. package/dist/components/wizard/step-sources.test.js +5 -5
  85. package/dist/components/wizard/step-stack.js +6 -6
  86. package/dist/components/wizard/step-stack.test.js +6 -6
  87. package/dist/components/wizard/wizard-layout.js +6 -6
  88. package/dist/components/wizard/wizard.js +14 -14
  89. package/dist/hooks/init.js +19 -16
  90. package/dist/hooks/init.js.map +1 -1
  91. package/dist/{loader-GT2A7R7U.js → loader-GSEGPK64.js} +3 -3
  92. package/dist/{source-loader-TNQW4P47.js → source-loader-OGFTIRIX.js} +4 -4
  93. package/dist/{source-manager-INRXRFJE.js → source-manager-FMMDDVZA.js} +4 -4
  94. package/dist/stores/wizard-store.js +4 -4
  95. package/dist/stores/wizard-store.test.js +4 -4
  96. package/package.json +1 -1
  97. package/dist/chunk-AABH2HSE.js +0 -340
  98. package/dist/chunk-AABH2HSE.js.map +0 -1
  99. package/dist/chunk-CYPCJ536.js.map +0 -1
  100. package/dist/chunk-FKXD3EXJ.js.map +0 -1
  101. package/dist/chunk-FT46LN7K.js.map +0 -1
  102. package/dist/chunk-TXW257CU.js.map +0 -1
  103. package/dist/chunk-WJKD6EGK.js.map +0 -1
  104. /package/dist/{chunk-6VGBO6SZ.js.map → chunk-5M6Q5UQO.js.map} +0 -0
  105. /package/dist/{chunk-YJ2URWF7.js.map → chunk-B6MYECV6.js.map} +0 -0
  106. /package/dist/{chunk-G2MINRWX.js.map → chunk-C5IYJ42F.js.map} +0 -0
  107. /package/dist/{chunk-7UZUDHP7.js.map → chunk-CXWBVBDM.js.map} +0 -0
  108. /package/dist/{chunk-LTFGEVTM.js.map → chunk-HH3AWXF4.js.map} +0 -0
  109. /package/dist/{chunk-2XVLQDNI.js.map → chunk-HSLVCKVQ.js.map} +0 -0
  110. /package/dist/{chunk-TAQGYJIS.js.map → chunk-HZ2IBXVQ.js.map} +0 -0
  111. /package/dist/{chunk-LN76TJJP.js.map → chunk-HZQOFFKA.js.map} +0 -0
  112. /package/dist/{chunk-W7LHI54P.js.map → chunk-I44YG6VI.js.map} +0 -0
  113. /package/dist/{chunk-L7COG2EX.js.map → chunk-LZ7XQ3IU.js.map} +0 -0
  114. /package/dist/{chunk-LMR7VAP3.js.map → chunk-MMTMXLI4.js.map} +0 -0
  115. /package/dist/{chunk-YYIWB42G.js.map → chunk-Q4DMIPZB.js.map} +0 -0
  116. /package/dist/{chunk-YSLDMYWP.js.map → chunk-SGZOFIFF.js.map} +0 -0
  117. /package/dist/{chunk-WCCWQ56J.js.map → chunk-UNEJKTLP.js.map} +0 -0
  118. /package/dist/{chunk-ZGD7PLLC.js.map → chunk-ZOWRO7UQ.js.map} +0 -0
  119. /package/dist/{loader-GT2A7R7U.js.map → loader-GSEGPK64.js.map} +0 -0
  120. /package/dist/{source-loader-TNQW4P47.js.map → source-loader-OGFTIRIX.js.map} +0 -0
  121. /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/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/discover-skills.ts","../src/cli/lib/operations/find-skill-match.ts","../src/cli/lib/operations/resolve-skill-info.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 { 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 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 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","// 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 { 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 {\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 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 resolveSkillInfo,\n type ResolveSkillInfoOptions,\n type ResolvedSkillInfo,\n type SkillInfoResult,\n} from \"./resolve-skill-info.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,OAAO,QAAQ;AAoBf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AClB,QAAI;AAEJ,QAAI,MAAM,SAAS,MAAM,WAAW;AAClC,oBAAcC,MAAK,KAAK,YAAY,MAAM,WAAW,eAAe,QAAQ;AAAA,IAC9E,OAAO;AACL,YAAM,YAAY,UAAU,aAAaA,MAAK,QAAQ,UAAU;AAChE,oBAAcA,MAAK,KAAK,WAAW,MAAM,MAAM,eAAe,QAAQ;AAAA,IACxE;AAEA,QAAI,MAAM,WAAW,WAAW,GAAG;AACjC,YAAM,UAAU,MAAM,SAAS,WAAW;AAC1C,gBAAU,gBAAgB,SAAS,qBAAqB;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU,EAAE,OAAO,aAAa,QAAQ;AAAA,IACxC,aAAa,CAAC;AAAA,EAChB;AACF;;;ACrJA;","names":["os","os","os","os","os","path","path","os","os","path","path","os","path","path"]}
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Wizard
4
- } from "./chunk-LN76TJJP.js";
4
+ } from "./chunk-HZQOFFKA.js";
5
5
  import {
6
6
  SelectList
7
7
  } from "./chunk-XO6X5QE5.js";
@@ -15,41 +15,39 @@ import {
15
15
  SUCCESS_MESSAGES
16
16
  } from "./chunk-B7KZLXHV.js";
17
17
  import {
18
- claudePluginInstall,
19
- claudePluginMarketplaceAdd,
20
- claudePluginMarketplaceExists,
21
- claudePluginMarketplaceUpdate,
22
- copySkillsToLocalFlattened,
18
+ compileAgents,
19
+ copyLocalSkills,
20
+ discoverInstalledSkills,
21
+ ensureMarketplace,
22
+ installPluginSkills,
23
+ loadAgentDefs,
24
+ loadSource,
25
+ writeProjectConfig
26
+ } from "./chunk-5UJJQFET.js";
27
+ import {
28
+ buildAgentScopeMap,
23
29
  deriveInstallMode,
24
30
  detectProjectInstallation,
25
31
  ensureBlankGlobalConfig,
26
- fetchMarketplace,
27
32
  getInstallationInfo,
28
- installLocal,
29
- installPluginConfig,
30
33
  loadProjectConfig,
31
- loadSkillsMatrixFromSource,
32
34
  resolveInstallPaths
33
- } from "./chunk-FKXD3EXJ.js";
35
+ } from "./chunk-TMTUTUEV.js";
34
36
  import {
35
37
  getSkillById
36
38
  } from "./chunk-ANXHMG32.js";
37
39
  import {
38
40
  BaseCommand,
39
41
  EXIT_CODES
40
- } from "./chunk-LMR7VAP3.js";
42
+ } from "./chunk-MMTMXLI4.js";
41
43
  import {
42
- disableBuffering,
43
- drainBuffer,
44
- enableBuffering,
45
- ensureDir,
46
44
  fileExists,
47
45
  getErrorMessage,
48
46
  readFileSafe,
49
47
  settingsFileSchema,
50
48
  warn,
51
49
  warnUnknownFields
52
- } from "./chunk-WJKD6EGK.js";
50
+ } from "./chunk-NUU3U43A.js";
53
51
  import {
54
52
  ASCII_LOGO,
55
53
  CLAUDE_DIR,
@@ -187,14 +185,6 @@ var Dashboard = ({ onSelect, onCancel }) => {
187
185
  ] })
188
186
  ] });
189
187
  };
190
- async function getDashboardData(projectDir) {
191
- const [info, loaded] = await Promise.all([getInstallationInfo(), loadProjectConfig(projectDir)]);
192
- const skillCount = loaded?.config?.skills?.length ?? 0;
193
- const agentCount = info?.agentCount ?? 0;
194
- const mode = info?.mode ?? (loaded?.config?.skills ? deriveInstallMode(loaded.config.skills) : "local");
195
- const source = loaded?.config?.source;
196
- return { skillCount, agentCount, mode, source };
197
- }
198
188
  function formatDashboardText(data) {
199
189
  const modeLabel = data.mode === "plugin" ? "Plugin" : data.mode === "mixed" ? "Mixed" : "Local";
200
190
  const lines = [
@@ -263,14 +253,26 @@ var Init = class _Init extends BaseCommand {
263
253
  async run() {
264
254
  const { flags } = await this.parse(_Init);
265
255
  const projectDir = process.cwd();
256
+ if (await this.showDashboardIfInitialized(projectDir)) return;
257
+ await this.ensureGlobalConfig(projectDir);
258
+ const { sourceResult, startupMessages } = await this.loadSourceOrFail(flags);
259
+ const result = await this.runWizard(sourceResult, startupMessages, projectDir);
260
+ if (!result) this.exit(EXIT_CODES.CANCELLED);
261
+ if (result.skills.length === 0) {
262
+ this.error("No skills selected", { exit: EXIT_CODES.ERROR });
263
+ }
264
+ await this.handleInstallation(result, sourceResult, flags);
265
+ }
266
+ async showDashboardIfInitialized(projectDir) {
266
267
  const existingInstallation = await detectProjectInstallation(projectDir);
267
- if (existingInstallation) {
268
- const selectedCommand = await showDashboard(projectDir, (msg) => this.log(msg));
269
- if (selectedCommand) {
270
- await this.config.runCommand(selectedCommand);
271
- }
272
- return;
268
+ if (!existingInstallation) return false;
269
+ const selectedCommand = await showDashboard(projectDir, (msg) => this.log(msg));
270
+ if (selectedCommand) {
271
+ await this.config.runCommand(selectedCommand);
273
272
  }
273
+ return true;
274
+ }
275
+ async ensureGlobalConfig(projectDir) {
274
276
  const isGlobalRoot = fs.realpathSync(projectDir) === fs.realpathSync(GLOBAL_INSTALL_ROOT);
275
277
  if (!isGlobalRoot) {
276
278
  const created = await ensureBlankGlobalConfig();
@@ -278,23 +280,23 @@ var Init = class _Init extends BaseCommand {
278
280
  this.log("Created blank global config at ~/" + CLAUDE_SRC_DIR);
279
281
  }
280
282
  }
281
- enableBuffering();
282
- let sourceResult;
283
- let startupMessages = [];
283
+ }
284
+ async loadSourceOrFail(flags) {
284
285
  try {
285
- sourceResult = await loadSkillsMatrixFromSource({
286
+ const loaded = await loadSource({
286
287
  sourceFlag: flags.source,
287
- projectDir,
288
- forceRefresh: flags.refresh
288
+ projectDir: process.cwd(),
289
+ forceRefresh: flags.refresh,
290
+ captureStartupMessages: true
289
291
  });
292
+ return { sourceResult: loaded.sourceResult, startupMessages: loaded.startupMessages };
290
293
  } catch (error) {
291
- disableBuffering();
292
294
  this.error(getErrorMessage(error), {
293
295
  exit: EXIT_CODES.ERROR
294
296
  });
295
297
  }
296
- startupMessages = drainBuffer();
297
- disableBuffering();
298
+ }
299
+ async runWizard(sourceResult, startupMessages, projectDir) {
298
300
  let wizardResult = null;
299
301
  const { waitUntilExit } = render(
300
302
  /* @__PURE__ */ jsx2(
@@ -315,204 +317,181 @@ var Init = class _Init extends BaseCommand {
315
317
  );
316
318
  await waitUntilExit();
317
319
  const result = wizardResult;
318
- if (!result || result.cancelled) {
319
- this.exit(EXIT_CODES.CANCELLED);
320
- }
321
- if (result.skills.length === 0) {
322
- this.error("No skills selected", { exit: EXIT_CODES.ERROR });
323
- }
324
- await this.handleInstallation(result, sourceResult, flags);
320
+ if (result?.cancelled) return null;
321
+ return result;
325
322
  }
326
323
  async handleInstallation(result, sourceResult, flags) {
327
324
  const projectDir = process.cwd();
328
- const installMode = deriveInstallMode(result.skills);
325
+ let installMode = deriveInstallMode(result.skills);
329
326
  const localSkills = result.skills.filter((s) => s.source === "local");
330
327
  const pluginSkills = result.skills.filter((s) => s.source !== "local");
328
+ this.logInstallPlan(result, installMode, localSkills, pluginSkills);
329
+ let copiedSkills = [...localSkills];
330
+ let pluginModeSucceeded = false;
331
+ if (installMode === "local" || installMode === "mixed") {
332
+ await this.copyLocalSkillsStep(localSkills, projectDir, sourceResult, installMode);
333
+ }
334
+ if (installMode === "plugin" || installMode === "mixed") {
335
+ const pluginStepResult = await this.installPluginsStep(
336
+ pluginSkills,
337
+ sourceResult,
338
+ projectDir,
339
+ installMode,
340
+ copiedSkills,
341
+ result.skills
342
+ );
343
+ copiedSkills = pluginStepResult.copiedSkills;
344
+ installMode = pluginStepResult.installMode;
345
+ pluginModeSucceeded = pluginStepResult.succeeded;
346
+ }
347
+ try {
348
+ const { configResult, compileResult, projectPaths } = await this.writeConfigAndCompile(
349
+ result,
350
+ sourceResult,
351
+ flags,
352
+ installMode
353
+ );
354
+ this.reportSuccess(
355
+ configResult,
356
+ compileResult,
357
+ projectPaths,
358
+ installMode,
359
+ pluginModeSucceeded,
360
+ copiedSkills
361
+ );
362
+ const permissionWarning = await checkPermissions(projectDir);
363
+ if (permissionWarning) {
364
+ const { waitUntilExit } = render(permissionWarning);
365
+ await waitUntilExit();
366
+ }
367
+ } catch (error) {
368
+ this.handleError(error);
369
+ }
370
+ }
371
+ logInstallPlan(result, installMode, localSkills, pluginSkills) {
331
372
  this.log("\n");
332
373
  this.log(`Selected ${result.skills.length} skills`);
333
374
  this.log(
334
375
  `Install mode: ${installMode === "plugin" ? "Plugin (native install)" : installMode === "mixed" ? `Mixed (${localSkills.length} local, ${pluginSkills.length} plugin)` : "Local (copy to .claude/skills/)"}`
335
376
  );
336
- if (installMode === "plugin") {
337
- await this.installIndividualPlugins(result, sourceResult, flags, projectDir);
338
- return;
339
- }
377
+ }
378
+ async copyLocalSkillsStep(localSkills, projectDir, sourceResult, installMode) {
379
+ this.log("Copying skills to local directory...");
380
+ const copyResult = await copyLocalSkills(localSkills, projectDir, sourceResult);
340
381
  if (installMode === "mixed") {
341
- const projectLocalSkills = localSkills.filter((s) => s.scope !== "global");
342
- const globalLocalSkills = localSkills.filter((s) => s.scope === "global");
343
- const projectPaths = resolveInstallPaths(projectDir, "project");
344
- const globalPaths = resolveInstallPaths(projectDir, "global");
345
- const projectCopied = projectLocalSkills.length > 0 ? (await ensureDir(projectPaths.skillsDir), await copySkillsToLocalFlattened(
346
- projectLocalSkills.map((s) => s.id),
347
- projectPaths.skillsDir,
348
- sourceResult.matrix,
349
- sourceResult
350
- )) : [];
351
- const globalCopied = globalLocalSkills.length > 0 ? (await ensureDir(globalPaths.skillsDir), await copySkillsToLocalFlattened(
352
- globalLocalSkills.map((s) => s.id),
353
- globalPaths.skillsDir,
354
- sourceResult.matrix,
355
- sourceResult
356
- )) : [];
357
- const totalCopied = projectCopied.length + globalCopied.length;
358
- if (projectCopied.length > 0 && globalCopied.length > 0) {
382
+ if (copyResult.projectCopied.length > 0 && copyResult.globalCopied.length > 0) {
359
383
  this.log(
360
- `Copied ${totalCopied} local skills (${projectCopied.length} project, ${globalCopied.length} global)`
384
+ `Copied ${copyResult.totalCopied} local skills (${copyResult.projectCopied.length} project, ${copyResult.globalCopied.length} global)`
361
385
  );
362
- } else if (globalCopied.length > 0) {
363
- this.log(`Copied ${globalCopied.length} local skills to ~/.claude/skills/`);
386
+ } else if (copyResult.globalCopied.length > 0) {
387
+ this.log(`Copied ${copyResult.globalCopied.length} local skills to ~/.claude/skills/`);
364
388
  } else {
365
- this.log(`Copied ${projectCopied.length} local skills to .claude/skills/`);
389
+ this.log(`Copied ${copyResult.projectCopied.length} local skills to .claude/skills/`);
366
390
  }
367
- await this.installIndividualPlugins(result, sourceResult, flags, projectDir);
368
- return;
391
+ } else {
392
+ this.log(`Copied ${copyResult.totalCopied} skills to .claude/skills/
393
+ `);
369
394
  }
370
- await this.installLocalMode(result, sourceResult, flags, projectDir);
371
395
  }
372
- async installIndividualPlugins(result, sourceResult, flags, projectDir) {
373
- if (!sourceResult.marketplace) {
374
- try {
375
- const marketplaceResult = await fetchMarketplace(sourceResult.sourceConfig.source, {});
376
- sourceResult.marketplace = marketplaceResult.marketplace.name;
377
- } catch {
378
- this.warn("Could not resolve marketplace. Falling back to Local Mode...");
379
- await this.installLocalMode(result, sourceResult, flags, projectDir);
380
- return;
381
- }
396
+ async installPluginsStep(pluginSkills, sourceResult, projectDir, installMode, copiedSkills, allSkills) {
397
+ const mpResult = await ensureMarketplace(sourceResult);
398
+ if (!mpResult.marketplace) {
399
+ this.warn("Could not resolve marketplace. Falling back to Local Mode...");
400
+ const fallbackSkills = installMode === "mixed" ? pluginSkills : allSkills;
401
+ const fallbackCopyResult = await copyLocalSkills(fallbackSkills, projectDir, sourceResult);
402
+ this.log(`Copied ${fallbackCopyResult.totalCopied} skills to .claude/skills/
403
+ `);
404
+ return {
405
+ copiedSkills: [...copiedSkills, ...fallbackSkills],
406
+ installMode: "local",
407
+ succeeded: false
408
+ };
382
409
  }
383
- const marketplace = sourceResult.marketplace;
384
- const marketplaceExists = await claudePluginMarketplaceExists(marketplace);
385
- if (!marketplaceExists) {
386
- this.log(`Registering marketplace "${marketplace}"...`);
387
- try {
388
- const marketplaceSource = sourceResult.sourceConfig.source.replace(/^github:/, "");
389
- await claudePluginMarketplaceAdd(marketplaceSource);
390
- this.log(`Registered marketplace: ${marketplace}`);
391
- } catch (error) {
392
- this.error(getErrorMessage(error), {
393
- exit: EXIT_CODES.ERROR
394
- });
395
- }
396
- } else {
397
- try {
398
- await claudePluginMarketplaceUpdate(marketplace);
399
- } catch (error) {
400
- this.warn(`Could not update marketplace \u2014 continuing with cached version`);
401
- }
410
+ if (mpResult.registered) {
411
+ this.log(`Registering marketplace "${mpResult.marketplace}"...`);
402
412
  }
403
413
  this.log("Installing skill plugins...");
404
- for (const skill of result.skills.filter((s) => s.source !== "local")) {
405
- const pluginRef = `${skill.id}@${marketplace}`;
406
- const pluginScope = skill.scope === "global" ? "user" : "project";
407
- try {
408
- await claudePluginInstall(pluginRef, pluginScope, projectDir);
409
- this.log(` Installed ${pluginRef}`);
410
- } catch (error) {
411
- this.error(`Failed to install plugin ${pluginRef}: ${getErrorMessage(error)}`, {
412
- exit: EXIT_CODES.ERROR
413
- });
414
- }
414
+ const pluginResult = await installPluginSkills(pluginSkills, mpResult.marketplace, projectDir);
415
+ for (const item of pluginResult.installed) {
416
+ this.log(` Installed ${item.ref}`);
415
417
  }
416
- const pluginSkillCount = result.skills.filter((s) => s.source !== "local").length;
417
- this.log(`Installed ${pluginSkillCount} skill plugins
418
+ for (const item of pluginResult.failed) {
419
+ this.warn(`Failed to install plugin ${item.id}: ${item.error}`);
420
+ }
421
+ this.log(`Installed ${pluginResult.installed.length} skill plugins
418
422
  `);
423
+ return { copiedSkills, installMode, succeeded: true };
424
+ }
425
+ async writeConfigAndCompile(result, sourceResult, flags, installMode) {
419
426
  this.log("Generating configuration...");
420
- try {
421
- const configResult = await installPluginConfig({
422
- wizardResult: result,
423
- sourceResult,
424
- projectDir,
425
- sourceFlag: flags.source
426
- });
427
- if (configResult.wasMerged) {
428
- this.log(`Merged with existing config at ${configResult.mergedConfigPath}`);
429
- }
430
- this.log(`Configuration saved (${configResult.config.agents.length} agents)
431
- `);
432
- this.log(STATUS_MESSAGES.COMPILING_AGENTS);
433
- this.log(`Compiled ${configResult.compiledAgents.length} agents to .claude/agents/
434
- `);
435
- this.log(`${SUCCESS_MESSAGES.INIT_SUCCESS}
436
- `);
437
- this.log("Agents compiled to:");
438
- this.log(` ${configResult.agentsDir}`);
439
- for (const agentName of configResult.compiledAgents) {
440
- this.log(` ${agentName}.md`);
441
- }
442
- this.log("");
443
- this.log("Configuration:");
444
- this.log(` ${configResult.configPath}`);
445
- this.log("");
446
- this.log("To customize agent-skill assignments:");
447
- this.log(` 1. Edit .claude-src/config.ts`);
448
- this.log(` 2. Run '${CLI_BIN_NAME} compile' to regenerate agents`);
449
- this.log("");
450
- const permissionWarning = await checkPermissions(projectDir);
451
- if (permissionWarning) {
452
- const { waitUntilExit } = render(permissionWarning);
453
- await waitUntilExit();
454
- }
455
- } catch (error) {
456
- this.handleError(error);
427
+ const configResult = await writeProjectConfig({
428
+ wizardResult: result,
429
+ sourceResult,
430
+ projectDir: process.cwd(),
431
+ sourceFlag: flags.source
432
+ });
433
+ if (configResult.wasMerged) {
434
+ this.log(`Merged with existing config at ${configResult.existingConfigPath}`);
457
435
  }
458
- }
459
- async installLocalMode(result, sourceResult, flags, projectDir) {
460
- this.log("Copying skills to local directory...");
461
- try {
462
- const installResult = await installLocal({
463
- wizardResult: result,
464
- sourceResult,
465
- projectDir,
466
- sourceFlag: flags.source
467
- });
468
- this.log(`Copied ${installResult.copiedSkills.length} skills to .claude/skills/
436
+ this.log(`Configuration saved (${configResult.config.agents.length} agents)
469
437
  `);
470
- this.log("Generating configuration...");
471
- if (installResult.wasMerged) {
472
- this.log(`Merged with existing config at ${installResult.mergedConfigPath}`);
473
- }
474
- this.log(`Configuration saved (${installResult.config.agents.length} agents)
438
+ this.log(STATUS_MESSAGES.COMPILING_AGENTS);
439
+ const projectPaths = resolveInstallPaths(process.cwd(), "project");
440
+ const agentDefs = await loadAgentDefs();
441
+ const { allSkills } = await discoverInstalledSkills(process.cwd());
442
+ const compileResult = await compileAgents({
443
+ projectDir: process.cwd(),
444
+ sourcePath: agentDefs.sourcePath,
445
+ skills: allSkills,
446
+ installMode,
447
+ agentScopeMap: buildAgentScopeMap(configResult.config),
448
+ outputDir: projectPaths.agentsDir
449
+ });
450
+ this.log(`Compiled ${compileResult.compiled.length} agents to .claude/agents/
475
451
  `);
476
- this.log(STATUS_MESSAGES.COMPILING_AGENTS);
477
- this.log(`Compiled ${installResult.compiledAgents.length} agents to .claude/agents/
478
- `);
479
- this.log(`${SUCCESS_MESSAGES.INIT_SUCCESS}
452
+ return { configResult, compileResult, projectPaths };
453
+ }
454
+ reportSuccess(configResult, compileResult, projectPaths, installMode, pluginModeSucceeded, copiedSkills) {
455
+ this.log(`${SUCCESS_MESSAGES.INIT_SUCCESS}
480
456
  `);
457
+ const isLocalOutput = installMode === "local" || installMode === "mixed" && !pluginModeSucceeded;
458
+ if (isLocalOutput && copiedSkills.length > 0) {
481
459
  this.log("Skills copied to:");
482
- this.log(` ${installResult.skillsDir}`);
483
- for (const copiedSkill of installResult.copiedSkills) {
484
- const displayName = getSkillById(copiedSkill.skillId).displayName;
460
+ this.log(` ${projectPaths.skillsDir}`);
461
+ for (const skill of copiedSkills) {
462
+ const displayName = getSkillById(skill.id).displayName;
485
463
  this.log(` ${displayName}/`);
486
464
  }
487
465
  this.log("");
488
- this.log("Agents compiled to:");
489
- this.log(` ${installResult.agentsDir}`);
490
- for (const agentName of installResult.compiledAgents) {
491
- this.log(` ${agentName}.md`);
492
- }
493
- this.log("");
494
- this.log("Configuration:");
495
- this.log(` ${installResult.configPath}`);
496
- this.log("");
497
- this.log("To customize agent-skill assignments:");
498
- this.log(` 1. Edit .claude-src/config.ts`);
499
- this.log(` 2. Run '${CLI_BIN_NAME} compile' to regenerate agents`);
500
- this.log("");
501
- const permissionWarning = await checkPermissions(projectDir);
502
- if (permissionWarning) {
503
- const { waitUntilExit } = render(permissionWarning);
504
- await waitUntilExit();
505
- }
506
- } catch (error) {
507
- this.handleError(error);
508
466
  }
467
+ this.log("Agents compiled to:");
468
+ this.log(` ${projectPaths.agentsDir}`);
469
+ for (const agentName of compileResult.compiled) {
470
+ this.log(` ${agentName}.md`);
471
+ }
472
+ this.log("");
473
+ this.log("Configuration:");
474
+ this.log(` ${configResult.configPath}`);
475
+ this.log("");
476
+ this.log("To customize agent-skill assignments:");
477
+ this.log(` 1. Edit .claude-src/config.ts`);
478
+ this.log(` 2. Run '${CLI_BIN_NAME} compile' to regenerate agents`);
479
+ this.log("");
509
480
  }
510
481
  };
482
+ async function getDashboardData(projectDir) {
483
+ const [info, loaded] = await Promise.all([getInstallationInfo(), loadProjectConfig(projectDir)]);
484
+ const skillCount = loaded?.config?.skills?.length ?? 0;
485
+ const agentCount = info?.agentCount ?? 0;
486
+ const mode = info?.mode ?? (loaded?.config?.skills ? deriveInstallMode(loaded.config.skills) : "local");
487
+ const source = loaded?.config?.source;
488
+ return { skillCount, agentCount, mode, source };
489
+ }
511
490
 
512
491
  export {
513
- getDashboardData,
514
492
  formatDashboardText,
515
493
  showDashboard,
516
- Init
494
+ Init,
495
+ getDashboardData
517
496
  };
518
- //# sourceMappingURL=chunk-TXW257CU.js.map
497
+ //# sourceMappingURL=chunk-7FFNNDJQ.js.map