@agents-inc/cli 0.86.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 (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/chunk-5UJJQFET.js +564 -0
  3. package/dist/chunk-5UJJQFET.js.map +1 -0
  4. package/dist/{chunk-GED2F75H.js → chunk-7FFNNDJQ.js} +176 -120
  5. package/dist/chunk-7FFNNDJQ.js.map +1 -0
  6. package/dist/{chunk-BV2MIQ3O.js → chunk-I5AZKNNL.js} +1 -1
  7. package/dist/chunk-I5AZKNNL.js.map +1 -0
  8. package/dist/chunk-J6PI73YV.js +68 -0
  9. package/dist/chunk-J6PI73YV.js.map +1 -0
  10. package/dist/commands/compile.js +26 -20
  11. package/dist/commands/compile.js.map +1 -1
  12. package/dist/commands/diff.js +681 -82
  13. package/dist/commands/diff.js.map +1 -1
  14. package/dist/commands/doctor.js +30 -58
  15. package/dist/commands/doctor.js.map +1 -1
  16. package/dist/commands/edit.js +164 -32
  17. package/dist/commands/edit.js.map +1 -1
  18. package/dist/commands/eject.js +177 -27
  19. package/dist/commands/eject.js.map +1 -1
  20. package/dist/commands/import/skill.js +197 -33
  21. package/dist/commands/import/skill.js.map +1 -1
  22. package/dist/commands/info.js +41 -34
  23. package/dist/commands/info.js.map +1 -1
  24. package/dist/commands/init.js +3 -6
  25. package/dist/commands/new/agent.js +140 -44
  26. package/dist/commands/new/agent.js.map +1 -1
  27. package/dist/commands/new/marketplace.js +4 -4
  28. package/dist/commands/new/marketplace.js.map +1 -1
  29. package/dist/commands/new/skill.js +194 -30
  30. package/dist/commands/new/skill.js.map +1 -1
  31. package/dist/commands/outdated.js +1 -3
  32. package/dist/commands/outdated.js.map +1 -1
  33. package/dist/commands/search.js +162 -65
  34. package/dist/commands/search.js.map +1 -1
  35. package/dist/commands/uninstall.js +259 -62
  36. package/dist/commands/uninstall.js.map +1 -1
  37. package/dist/commands/update.js +232 -163
  38. package/dist/commands/update.js.map +1 -1
  39. package/dist/components/skill-search/skill-search.js +1 -1
  40. package/dist/hooks/init.js +2 -4
  41. package/dist/hooks/init.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-BV2MIQ3O.js.map +0 -1
  44. package/dist/chunk-DCVCFBQ7.js +0 -1800
  45. package/dist/chunk-DCVCFBQ7.js.map +0 -1
  46. package/dist/chunk-GED2F75H.js.map +0 -1
  47. package/dist/chunk-O5ZWS26C.js +0 -166
  48. package/dist/chunk-O5ZWS26C.js.map +0 -1
  49. package/dist/chunk-XQK4S22C.js +0 -202
  50. package/dist/chunk-XQK4S22C.js.map +0 -1
@@ -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,eAAsB,wBAAwB,YAAgD;AAC5F,QAAM,SAAS,MAAM,yBAAyB;AAC9C,QAAM,UAAU,eAAe,GAAG,QAAQ,IAAI,OAAO,MAAM,0BAA0B,UAAU;AAC/F,SAAO,EAAE,QAAQ,SAAS,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ;AAC3D;;;ACxBA;AA+BA,eAAsB,WAAW,SAAmD;AAClF,QAAM,EAAE,YAAY,YAAY,cAAc,uBAAuB,IAAI;AAEzE,MAAI,wBAAwB;AAC1B,oBAAgB;AAAA,EAClB;AAEA,MAAI;AACJ,MAAI;AACF,mBAAe,MAAM,2BAA2B;AAAA,MAC9C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,QAAI,wBAAwB;AAC1B,uBAAiB;AAAA,IACnB;AACA,UAAM;AAAA,EACR;AAEA,MAAI,kBAAoC,CAAC;AACzC,MAAI,wBAAwB;AAC1B,sBAAkB,YAAY;AAC9B,qBAAiB;AAAA,EACnB;AAEA,SAAO,EAAE,cAAc,gBAAgB;AACzC;;;AC3DA;AAmBA,eAAsB,cAAc,YAAsD;AACxF,QAAM,cAAc,cAAc,QAAQ,IAAI;AAC9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OAAO,QAAQ,UAAU,YAAY,YAAY,SAAS,eAAe,IAAI;AAGrF,QAAM,iBAAiB,SAAS,KAAkB;AAClD,QAAM,QAAQ,OAAO,KAAgB,MAAM,iBAAiB,OAAO,cAAc,IAAI;AAErF,MAAI,CAAC,OAAO;AACV,UAAM,cAAc,gBAAgB,QAAQ,OAAO,eAAe;AAClE,WAAO,EAAE,UAAU,MAAM,YAAY;AAAA,EACvC;AAEA,QAAM,oBAAoB,MAAM,oBAAoB,UAAU;AAC9D,QAAM,gBAAgB,mBAAmB,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC;AACrE,QAAM,cAAc,cAAc,SAAS,MAAM,EAAE;AAEnD,MAAI,UAAoB,CAAC;AACzB,MAAI,gBAAgB;AAClB,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"]}
@@ -17,18 +17,20 @@ import {
17
17
  import {
18
18
  compileAgents,
19
19
  copyLocalSkills,
20
+ discoverInstalledSkills,
20
21
  ensureMarketplace,
21
- getDashboardData,
22
22
  installPluginSkills,
23
23
  loadAgentDefs,
24
24
  loadSource,
25
25
  writeProjectConfig
26
- } from "./chunk-DCVCFBQ7.js";
26
+ } from "./chunk-5UJJQFET.js";
27
27
  import {
28
28
  buildAgentScopeMap,
29
29
  deriveInstallMode,
30
30
  detectProjectInstallation,
31
31
  ensureBlankGlobalConfig,
32
+ getInstallationInfo,
33
+ loadProjectConfig,
32
34
  resolveInstallPaths
33
35
  } from "./chunk-TMTUTUEV.js";
34
36
  import {
@@ -251,14 +253,26 @@ var Init = class _Init extends BaseCommand {
251
253
  async run() {
252
254
  const { flags } = await this.parse(_Init);
253
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) {
254
267
  const existingInstallation = await detectProjectInstallation(projectDir);
255
- if (existingInstallation) {
256
- const selectedCommand = await showDashboard(projectDir, (msg) => this.log(msg));
257
- if (selectedCommand) {
258
- await this.config.runCommand(selectedCommand);
259
- }
260
- 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);
261
272
  }
273
+ return true;
274
+ }
275
+ async ensureGlobalConfig(projectDir) {
262
276
  const isGlobalRoot = fs.realpathSync(projectDir) === fs.realpathSync(GLOBAL_INSTALL_ROOT);
263
277
  if (!isGlobalRoot) {
264
278
  const created = await ensureBlankGlobalConfig();
@@ -266,22 +280,23 @@ var Init = class _Init extends BaseCommand {
266
280
  this.log("Created blank global config at ~/" + CLAUDE_SRC_DIR);
267
281
  }
268
282
  }
269
- let sourceResult;
270
- let startupMessages = [];
283
+ }
284
+ async loadSourceOrFail(flags) {
271
285
  try {
272
286
  const loaded = await loadSource({
273
287
  sourceFlag: flags.source,
274
- projectDir,
288
+ projectDir: process.cwd(),
275
289
  forceRefresh: flags.refresh,
276
290
  captureStartupMessages: true
277
291
  });
278
- sourceResult = loaded.sourceResult;
279
- startupMessages = loaded.startupMessages;
292
+ return { sourceResult: loaded.sourceResult, startupMessages: loaded.startupMessages };
280
293
  } catch (error) {
281
294
  this.error(getErrorMessage(error), {
282
295
  exit: EXIT_CODES.ERROR
283
296
  });
284
297
  }
298
+ }
299
+ async runWizard(sourceResult, startupMessages, projectDir) {
285
300
  let wizardResult = null;
286
301
  const { waitUntilExit } = render(
287
302
  /* @__PURE__ */ jsx2(
@@ -302,140 +317,181 @@ var Init = class _Init extends BaseCommand {
302
317
  );
303
318
  await waitUntilExit();
304
319
  const result = wizardResult;
305
- if (!result || result.cancelled) {
306
- this.exit(EXIT_CODES.CANCELLED);
307
- }
308
- if (result.skills.length === 0) {
309
- this.error("No skills selected", { exit: EXIT_CODES.ERROR });
310
- }
311
- await this.handleInstallation(result, sourceResult, flags);
320
+ if (result?.cancelled) return null;
321
+ return result;
312
322
  }
313
323
  async handleInstallation(result, sourceResult, flags) {
314
324
  const projectDir = process.cwd();
315
325
  let installMode = deriveInstallMode(result.skills);
316
326
  const localSkills = result.skills.filter((s) => s.source === "local");
317
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) {
318
372
  this.log("\n");
319
373
  this.log(`Selected ${result.skills.length} skills`);
320
374
  this.log(
321
375
  `Install mode: ${installMode === "plugin" ? "Plugin (native install)" : installMode === "mixed" ? `Mixed (${localSkills.length} local, ${pluginSkills.length} plugin)` : "Local (copy to .claude/skills/)"}`
322
376
  );
323
- let copiedSkills = [];
324
- if (installMode === "local" || installMode === "mixed") {
325
- this.log("Copying skills to local directory...");
326
- const copyResult = await copyLocalSkills(localSkills, projectDir, sourceResult);
327
- copiedSkills = localSkills;
328
- if (installMode === "mixed") {
329
- if (copyResult.projectCopied.length > 0 && copyResult.globalCopied.length > 0) {
330
- this.log(
331
- `Copied ${copyResult.totalCopied} local skills (${copyResult.projectCopied.length} project, ${copyResult.globalCopied.length} global)`
332
- );
333
- } else if (copyResult.globalCopied.length > 0) {
334
- this.log(`Copied ${copyResult.globalCopied.length} local skills to ~/.claude/skills/`);
335
- } else {
336
- this.log(`Copied ${copyResult.projectCopied.length} local skills to .claude/skills/`);
337
- }
377
+ }
378
+ async copyLocalSkillsStep(localSkills, projectDir, sourceResult, installMode) {
379
+ this.log("Copying skills to local directory...");
380
+ const copyResult = await copyLocalSkills(localSkills, projectDir, sourceResult);
381
+ if (installMode === "mixed") {
382
+ if (copyResult.projectCopied.length > 0 && copyResult.globalCopied.length > 0) {
383
+ this.log(
384
+ `Copied ${copyResult.totalCopied} local skills (${copyResult.projectCopied.length} project, ${copyResult.globalCopied.length} global)`
385
+ );
386
+ } else if (copyResult.globalCopied.length > 0) {
387
+ this.log(`Copied ${copyResult.globalCopied.length} local skills to ~/.claude/skills/`);
338
388
  } else {
339
- this.log(`Copied ${copyResult.totalCopied} skills to .claude/skills/
340
- `);
389
+ this.log(`Copied ${copyResult.projectCopied.length} local skills to .claude/skills/`);
341
390
  }
342
- }
343
- let pluginModeSucceeded = false;
344
- if (installMode === "plugin" || installMode === "mixed") {
345
- const mpResult = await ensureMarketplace(sourceResult);
346
- if (!mpResult.marketplace) {
347
- this.warn("Could not resolve marketplace. Falling back to Local Mode...");
348
- const fallbackSkills = installMode === "mixed" ? pluginSkills : result.skills;
349
- const fallbackCopyResult = await copyLocalSkills(fallbackSkills, projectDir, sourceResult);
350
- copiedSkills = [...copiedSkills, ...fallbackSkills];
351
- installMode = "local";
352
- this.log(`Copied ${fallbackCopyResult.totalCopied} skills to .claude/skills/
391
+ } else {
392
+ this.log(`Copied ${copyResult.totalCopied} skills to .claude/skills/
353
393
  `);
354
- } else {
355
- if (mpResult.registered) {
356
- this.log(`Registering marketplace "${mpResult.marketplace}"...`);
357
- }
358
- this.log("Installing skill plugins...");
359
- const pluginResult = await installPluginSkills(
360
- pluginSkills,
361
- mpResult.marketplace,
362
- projectDir
363
- );
364
- for (const item of pluginResult.installed) {
365
- this.log(` Installed ${item.ref}`);
366
- }
367
- for (const item of pluginResult.failed) {
368
- this.warn(`Failed to install plugin ${item.id}: ${item.error}`);
369
- }
370
- this.log(`Installed ${pluginResult.installed.length} skill plugins
394
+ }
395
+ }
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/
371
403
  `);
372
- pluginModeSucceeded = true;
373
- }
404
+ return {
405
+ copiedSkills: [...copiedSkills, ...fallbackSkills],
406
+ installMode: "local",
407
+ succeeded: false
408
+ };
409
+ }
410
+ if (mpResult.registered) {
411
+ this.log(`Registering marketplace "${mpResult.marketplace}"...`);
412
+ }
413
+ this.log("Installing skill plugins...");
414
+ const pluginResult = await installPluginSkills(pluginSkills, mpResult.marketplace, projectDir);
415
+ for (const item of pluginResult.installed) {
416
+ this.log(` Installed ${item.ref}`);
417
+ }
418
+ for (const item of pluginResult.failed) {
419
+ this.warn(`Failed to install plugin ${item.id}: ${item.error}`);
374
420
  }
421
+ this.log(`Installed ${pluginResult.installed.length} skill plugins
422
+ `);
423
+ return { copiedSkills, installMode, succeeded: true };
424
+ }
425
+ async writeConfigAndCompile(result, sourceResult, flags, installMode) {
375
426
  this.log("Generating configuration...");
376
- try {
377
- const configResult = await writeProjectConfig({
378
- wizardResult: result,
379
- sourceResult,
380
- projectDir,
381
- sourceFlag: flags.source
382
- });
383
- if (configResult.wasMerged) {
384
- this.log(`Merged with existing config at ${configResult.existingConfigPath}`);
385
- }
386
- this.log(`Configuration saved (${configResult.config.agents.length} agents)
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}`);
435
+ }
436
+ this.log(`Configuration saved (${configResult.config.agents.length} agents)
387
437
  `);
388
- this.log(STATUS_MESSAGES.COMPILING_AGENTS);
389
- const projectPaths = resolveInstallPaths(projectDir, "project");
390
- const agentDefs = await loadAgentDefs();
391
- const compileResult = await compileAgents({
392
- projectDir,
393
- sourcePath: agentDefs.sourcePath,
394
- installMode,
395
- agentScopeMap: buildAgentScopeMap(configResult.config),
396
- outputDir: projectPaths.agentsDir
397
- });
398
- this.log(`Compiled ${compileResult.compiled.length} agents to .claude/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/
399
451
  `);
400
- 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}
401
456
  `);
402
- const isLocalOutput = installMode === "local" || installMode === "mixed" && !pluginModeSucceeded;
403
- if (isLocalOutput && copiedSkills.length > 0) {
404
- this.log("Skills copied to:");
405
- this.log(` ${projectPaths.skillsDir}`);
406
- for (const skill of copiedSkills) {
407
- const displayName = getSkillById(skill.id).displayName;
408
- this.log(` ${displayName}/`);
409
- }
410
- this.log("");
457
+ const isLocalOutput = installMode === "local" || installMode === "mixed" && !pluginModeSucceeded;
458
+ if (isLocalOutput && copiedSkills.length > 0) {
459
+ this.log("Skills copied to:");
460
+ this.log(` ${projectPaths.skillsDir}`);
461
+ for (const skill of copiedSkills) {
462
+ const displayName = getSkillById(skill.id).displayName;
463
+ this.log(` ${displayName}/`);
411
464
  }
412
- this.log("Agents compiled to:");
413
- this.log(` ${projectPaths.agentsDir}`);
414
- for (const agentName of compileResult.compiled) {
415
- this.log(` ${agentName}.md`);
416
- }
417
- this.log("");
418
- this.log("Configuration:");
419
- this.log(` ${configResult.configPath}`);
420
465
  this.log("");
421
- this.log("To customize agent-skill assignments:");
422
- this.log(` 1. Edit .claude-src/config.ts`);
423
- this.log(` 2. Run '${CLI_BIN_NAME} compile' to regenerate agents`);
424
- this.log("");
425
- const permissionWarning = await checkPermissions(projectDir);
426
- if (permissionWarning) {
427
- const { waitUntilExit } = render(permissionWarning);
428
- await waitUntilExit();
429
- }
430
- } catch (error) {
431
- this.handleError(error);
432
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("");
433
480
  }
434
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
+ }
435
490
 
436
491
  export {
437
492
  formatDashboardText,
438
493
  showDashboard,
439
- Init
494
+ Init,
495
+ getDashboardData
440
496
  };
441
- //# sourceMappingURL=chunk-GED2F75H.js.map
497
+ //# sourceMappingURL=chunk-7FFNNDJQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/init.tsx","../src/cli/lib/permission-checker.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { Flags } from \"@oclif/core\";\nimport { render, Box, Text, useApp } from \"ink\";\nimport fs from \"fs\";\n\nimport { BaseCommand } from \"../base-command.js\";\nimport { Wizard, type WizardResultV2 } from \"../components/wizard/wizard.js\";\nimport { type SourceLoadResult } from \"../lib/loading/index.js\";\nimport {\n loadSource,\n loadAgentDefs,\n copyLocalSkills,\n ensureMarketplace,\n installPluginSkills,\n writeProjectConfig,\n compileAgents,\n discoverInstalledSkills,\n} from \"../lib/operations/index.js\";\nimport { getInstallationInfo } from \"../lib/plugins/plugin-info.js\";\nimport { loadProjectConfig } from \"../lib/configuration/project-config.js\";\nimport {\n type InstallMode,\n detectProjectInstallation,\n deriveInstallMode,\n resolveInstallPaths,\n buildAgentScopeMap,\n} from \"../lib/installation/index.js\";\nimport { checkPermissions } from \"../lib/permission-checker.js\";\nimport {\n ASCII_LOGO,\n CLAUDE_SRC_DIR,\n CLI_BIN_NAME,\n DEFAULT_BRANDING,\n GLOBAL_INSTALL_ROOT,\n} from \"../consts.js\";\nimport { SelectList, type SelectListItem } from \"../components/common/select-list.js\";\nimport {\n KEY_LABEL_ARROWS_VERT,\n KEY_LABEL_ENTER,\n KEY_LABEL_ESC,\n} from \"../components/wizard/hotkeys.js\";\nimport { getErrorMessage } from \"../utils/errors.js\";\nimport { EXIT_CODES } from \"../lib/exit-codes.js\";\nimport { getSkillById } from \"../lib/matrix/matrix-provider\";\nimport { type StartupMessage } from \"../utils/logger.js\";\nimport { SUCCESS_MESSAGES, STATUS_MESSAGES } from \"../utils/messages.js\";\nimport { ensureBlankGlobalConfig } from \"../lib/configuration/config-writer.js\";\n\n/** Clears the visible terminal area so the next render starts clean. */\nfunction clearTerminalOutput(): void {\n process.stdout.write(\"\\x1b[2J\\x1b[H\");\n}\n\nconst DASHBOARD_OPTIONS: SelectListItem<string>[] = [\n { label: \"Edit\", value: \"edit\" },\n { label: \"Compile\", value: \"compile\" },\n { label: \"Doctor\", value: \"doctor\" },\n { label: \"List\", value: \"list\" },\n];\n\ntype DashboardProps = {\n onSelect: (command: string) => void;\n onCancel: () => void;\n};\n\nconst Dashboard: React.FC<DashboardProps> = ({ onSelect, onCancel }) => {\n const { exit } = useApp();\n\n return (\n <Box flexDirection=\"column\">\n <Text bold>{DEFAULT_BRANDING.NAME}</Text>\n <Text> </Text>\n <SelectList\n items={DASHBOARD_OPTIONS}\n onSelect={(command) => {\n onSelect(command);\n exit();\n }}\n onCancel={() => {\n onCancel();\n exit();\n }}\n />\n <Text> </Text>\n <Text dimColor>\n {\" \"}\n {KEY_LABEL_ARROWS_VERT} Navigate {\" \"}\n {KEY_LABEL_ENTER} Confirm {\" \"}\n {KEY_LABEL_ESC} Exit\n </Text>\n </Box>\n );\n};\n\n/** Formats the dashboard summary as plain text lines (for non-interactive/test output). */\nexport function formatDashboardText(data: DashboardData): string {\n const modeLabel = data.mode === \"plugin\" ? \"Plugin\" : data.mode === \"mixed\" ? \"Mixed\" : \"Local\";\n const lines = [\n DEFAULT_BRANDING.NAME,\n \"\",\n ` Skills: ${data.skillCount} installed`,\n ` Agents: ${data.agentCount} compiled`,\n ` Mode: ${modeLabel}`,\n ];\n if (data.source) {\n lines.push(` Source: ${data.source}`);\n }\n lines.push(\"\");\n lines.push(` [Edit] [Compile] [Doctor] [List]`);\n return lines.join(\"\\n\");\n}\n\n/**\n * Shows the project dashboard and returns the selected command (or null if cancelled).\n * In non-interactive environments (no TTY), prints the summary text and returns null.\n */\nexport async function showDashboard(\n projectDir: string,\n log?: (message: string) => void,\n): Promise<string | null> {\n const data = await getDashboardData(projectDir);\n\n // Non-interactive: print text summary and exit (CI, piped, tests)\n if (!process.stdin.isTTY) {\n const output = log ?? console.log;\n output(formatDashboardText(data));\n return null;\n }\n\n let selectedCommand: string | null = null;\n\n const { waitUntilExit } = render(\n <Dashboard\n onSelect={(command) => {\n selectedCommand = command;\n }}\n onCancel={() => {\n selectedCommand = null;\n }}\n />,\n );\n\n await waitUntilExit();\n clearTerminalOutput();\n\n return selectedCommand;\n}\n\nexport default class Init extends BaseCommand {\n static summary = `Initialize ${DEFAULT_BRANDING.NAME} in this project`;\n static description =\n \"Interactive wizard to set up skills and agents. Supports Plugin Mode (native install) and Local Mode (copy to .claude/).\";\n\n static examples = [\n {\n description: \"Start the setup wizard\",\n command: \"<%= config.bin %> <%= command.id %>\",\n },\n {\n description: \"Initialize from a custom marketplace\",\n command: \"<%= config.bin %> <%= command.id %> --source github:org/marketplace\",\n },\n {\n description: \"Force refresh skills from remote\",\n command: \"<%= config.bin %> <%= command.id %> --refresh\",\n },\n ];\n\n static flags = {\n ...BaseCommand.baseFlags,\n refresh: Flags.boolean({\n description: \"Force refresh from remote source\",\n default: false,\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Init);\n const projectDir = process.cwd();\n\n if (await this.showDashboardIfInitialized(projectDir)) return;\n await this.ensureGlobalConfig(projectDir);\n\n const { sourceResult, startupMessages } = await this.loadSourceOrFail(flags);\n const result = await this.runWizard(sourceResult, startupMessages, projectDir);\n if (!result) this.exit(EXIT_CODES.CANCELLED);\n\n if (result.skills.length === 0) {\n this.error(\"No skills selected\", { exit: EXIT_CODES.ERROR });\n }\n\n await this.handleInstallation(result, sourceResult, flags);\n }\n\n private async showDashboardIfInitialized(projectDir: string): Promise<boolean> {\n const existingInstallation = await detectProjectInstallation(projectDir);\n if (!existingInstallation) return false;\n\n const selectedCommand = await showDashboard(projectDir, (msg) => this.log(msg));\n if (selectedCommand) {\n await this.config.runCommand(selectedCommand);\n }\n return true;\n }\n\n private async ensureGlobalConfig(projectDir: string): Promise<void> {\n // Auto-create blank global config on first init from a project directory.\n // This ensures the project config can always import from global.\n // Resolve both paths through realpathSync — on macOS /var is a symlink to\n // /private/var, so os.homedir() and process.cwd() can return different\n // prefixes for the same directory.\n const isGlobalRoot = fs.realpathSync(projectDir) === fs.realpathSync(GLOBAL_INSTALL_ROOT);\n if (!isGlobalRoot) {\n const created = await ensureBlankGlobalConfig();\n if (created) {\n this.log(\"Created blank global config at ~/\" + CLAUDE_SRC_DIR);\n }\n }\n }\n\n private async loadSourceOrFail(flags: {\n source?: string;\n refresh: boolean;\n }): Promise<{ sourceResult: SourceLoadResult; startupMessages: StartupMessage[] }> {\n try {\n const loaded = await loadSource({\n sourceFlag: flags.source,\n projectDir: process.cwd(),\n forceRefresh: flags.refresh,\n captureStartupMessages: true,\n });\n return { sourceResult: loaded.sourceResult, startupMessages: loaded.startupMessages };\n } catch (error) {\n this.error(getErrorMessage(error), {\n exit: EXIT_CODES.ERROR,\n });\n }\n }\n\n private async runWizard(\n sourceResult: SourceLoadResult,\n startupMessages: StartupMessage[],\n projectDir: string,\n ): Promise<WizardResultV2 | null> {\n let wizardResult: WizardResultV2 | null = null;\n\n const { waitUntilExit } = render(\n <Wizard\n version={this.config.version}\n logo={ASCII_LOGO}\n projectDir={projectDir}\n startupMessages={startupMessages}\n onComplete={(result) => {\n wizardResult = result;\n }}\n onCancel={() => {\n this.log(\"Setup cancelled\");\n }}\n />,\n );\n\n await waitUntilExit();\n\n // TypeScript can't track that onComplete callback mutates wizardResult before waitUntilExit resolves\n const result = wizardResult as WizardResultV2 | null;\n if (result?.cancelled) return null;\n return result;\n }\n\n private async handleInstallation(\n result: WizardResultV2,\n sourceResult: SourceLoadResult,\n flags: { source?: string; refresh: boolean },\n ): Promise<void> {\n const projectDir = process.cwd();\n let installMode = deriveInstallMode(result.skills);\n const localSkills = result.skills.filter((s) => s.source === \"local\");\n const pluginSkills = result.skills.filter((s) => s.source !== \"local\");\n\n this.logInstallPlan(result, installMode, localSkills, pluginSkills);\n\n let copiedSkills = [...localSkills];\n let pluginModeSucceeded = false;\n\n if (installMode === \"local\" || installMode === \"mixed\") {\n await this.copyLocalSkillsStep(localSkills, projectDir, sourceResult, installMode);\n }\n\n if (installMode === \"plugin\" || installMode === \"mixed\") {\n const pluginStepResult = await this.installPluginsStep(\n pluginSkills,\n sourceResult,\n projectDir,\n installMode,\n copiedSkills,\n result.skills,\n );\n copiedSkills = pluginStepResult.copiedSkills;\n installMode = pluginStepResult.installMode;\n pluginModeSucceeded = pluginStepResult.succeeded;\n }\n\n try {\n const { configResult, compileResult, projectPaths } = await this.writeConfigAndCompile(\n result,\n sourceResult,\n flags,\n installMode,\n );\n this.reportSuccess(\n configResult,\n compileResult,\n projectPaths,\n installMode,\n pluginModeSucceeded,\n copiedSkills,\n );\n\n const permissionWarning = await checkPermissions(projectDir);\n if (permissionWarning) {\n const { waitUntilExit } = render(permissionWarning);\n await waitUntilExit();\n }\n } catch (error) {\n this.handleError(error);\n }\n }\n\n private logInstallPlan(\n result: WizardResultV2,\n installMode: InstallMode,\n localSkills: WizardResultV2[\"skills\"],\n pluginSkills: WizardResultV2[\"skills\"],\n ): void {\n this.log(\"\\n\");\n this.log(`Selected ${result.skills.length} skills`);\n this.log(\n `Install mode: ${\n installMode === \"plugin\"\n ? \"Plugin (native install)\"\n : installMode === \"mixed\"\n ? `Mixed (${localSkills.length} local, ${pluginSkills.length} plugin)`\n : \"Local (copy to .claude/skills/)\"\n }`,\n );\n }\n\n private async copyLocalSkillsStep(\n localSkills: WizardResultV2[\"skills\"],\n projectDir: string,\n sourceResult: SourceLoadResult,\n installMode: InstallMode,\n ): Promise<void> {\n this.log(\"Copying skills to local directory...\");\n const copyResult = await copyLocalSkills(localSkills, projectDir, sourceResult);\n\n if (installMode === \"mixed\") {\n if (copyResult.projectCopied.length > 0 && copyResult.globalCopied.length > 0) {\n this.log(\n `Copied ${copyResult.totalCopied} local skills (${copyResult.projectCopied.length} project, ${copyResult.globalCopied.length} global)`,\n );\n } else if (copyResult.globalCopied.length > 0) {\n this.log(`Copied ${copyResult.globalCopied.length} local skills to ~/.claude/skills/`);\n } else {\n this.log(`Copied ${copyResult.projectCopied.length} local skills to .claude/skills/`);\n }\n } else {\n this.log(`Copied ${copyResult.totalCopied} skills to .claude/skills/\\n`);\n }\n }\n\n private async installPluginsStep(\n pluginSkills: WizardResultV2[\"skills\"],\n sourceResult: SourceLoadResult,\n projectDir: string,\n installMode: InstallMode,\n copiedSkills: WizardResultV2[\"skills\"],\n allSkills: WizardResultV2[\"skills\"],\n ): Promise<{\n copiedSkills: WizardResultV2[\"skills\"];\n installMode: InstallMode;\n succeeded: boolean;\n }> {\n const mpResult = await ensureMarketplace(sourceResult);\n\n if (!mpResult.marketplace) {\n this.warn(\"Could not resolve marketplace. Falling back to Local Mode...\");\n // Marketplace unavailable — copy all plugin-intended skills locally as fallback.\n // In \"mixed\" mode, localSkills were already copied; only copy plugin-intended skills.\n // In \"plugin\" mode, no skills were copied yet; copy all skills.\n const fallbackSkills = installMode === \"mixed\" ? pluginSkills : allSkills;\n const fallbackCopyResult = await copyLocalSkills(fallbackSkills, projectDir, sourceResult);\n this.log(`Copied ${fallbackCopyResult.totalCopied} skills to .claude/skills/\\n`);\n return {\n copiedSkills: [...copiedSkills, ...fallbackSkills],\n installMode: \"local\",\n succeeded: false,\n };\n }\n\n if (mpResult.registered) {\n this.log(`Registering marketplace \"${mpResult.marketplace}\"...`);\n }\n\n this.log(\"Installing skill plugins...\");\n const pluginResult = await installPluginSkills(pluginSkills, mpResult.marketplace, projectDir);\n\n for (const item of pluginResult.installed) {\n this.log(` Installed ${item.ref}`);\n }\n for (const item of pluginResult.failed) {\n this.warn(`Failed to install plugin ${item.id}: ${item.error}`);\n }\n\n this.log(`Installed ${pluginResult.installed.length} skill plugins\\n`);\n return { copiedSkills, installMode, succeeded: true };\n }\n\n private async writeConfigAndCompile(\n result: WizardResultV2,\n sourceResult: SourceLoadResult,\n flags: { source?: string; refresh: boolean },\n installMode: InstallMode,\n ): Promise<{\n configResult: Awaited<ReturnType<typeof writeProjectConfig>>;\n compileResult: Awaited<ReturnType<typeof compileAgents>>;\n projectPaths: ReturnType<typeof resolveInstallPaths>;\n }> {\n this.log(\"Generating configuration...\");\n const configResult = await writeProjectConfig({\n wizardResult: result,\n sourceResult,\n projectDir: process.cwd(),\n sourceFlag: flags.source,\n });\n\n if (configResult.wasMerged) {\n this.log(`Merged with existing config at ${configResult.existingConfigPath}`);\n }\n\n this.log(`Configuration saved (${configResult.config.agents.length} agents)\\n`);\n\n this.log(STATUS_MESSAGES.COMPILING_AGENTS);\n const projectPaths = resolveInstallPaths(process.cwd(), \"project\");\n const agentDefs = await loadAgentDefs();\n const { allSkills } = await discoverInstalledSkills(process.cwd());\n const compileResult = await compileAgents({\n projectDir: process.cwd(),\n sourcePath: agentDefs.sourcePath,\n skills: allSkills,\n installMode,\n agentScopeMap: buildAgentScopeMap(configResult.config),\n outputDir: projectPaths.agentsDir,\n });\n this.log(`Compiled ${compileResult.compiled.length} agents to .claude/agents/\\n`);\n\n return { configResult, compileResult, projectPaths };\n }\n\n private reportSuccess(\n configResult: Awaited<ReturnType<typeof writeProjectConfig>>,\n compileResult: Awaited<ReturnType<typeof compileAgents>>,\n projectPaths: ReturnType<typeof resolveInstallPaths>,\n installMode: InstallMode,\n pluginModeSucceeded: boolean,\n copiedSkills: WizardResultV2[\"skills\"],\n ): void {\n this.log(`${SUCCESS_MESSAGES.INIT_SUCCESS}\\n`);\n\n const isLocalOutput =\n installMode === \"local\" || (installMode === \"mixed\" && !pluginModeSucceeded);\n if (isLocalOutput && copiedSkills.length > 0) {\n this.log(\"Skills copied to:\");\n this.log(` ${projectPaths.skillsDir}`);\n for (const skill of copiedSkills) {\n const displayName = getSkillById(skill.id).displayName;\n this.log(` ${displayName}/`);\n }\n this.log(\"\");\n }\n this.log(\"Agents compiled to:\");\n this.log(` ${projectPaths.agentsDir}`);\n for (const agentName of compileResult.compiled) {\n this.log(` ${agentName}.md`);\n }\n this.log(\"\");\n this.log(\"Configuration:\");\n this.log(` ${configResult.configPath}`);\n this.log(\"\");\n this.log(\"To customize agent-skill assignments:\");\n this.log(` 1. Edit .claude-src/config.ts`);\n this.log(` 2. Run '${CLI_BIN_NAME} compile' to regenerate agents`);\n this.log(\"\");\n }\n}\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 const skillCount = loaded?.config?.skills?.length ?? 0;\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 React from \"react\";\n\nimport { Text, Box } from \"ink\";\nimport path from \"path\";\n\nimport { CLAUDE_DIR, CLI_COLORS, MAX_CONFIG_FILE_SIZE } from \"../consts\";\nimport { fileExists, readFileSafe } from \"../utils/fs\";\nimport { warn } from \"../utils/logger\";\nimport { settingsFileSchema, warnUnknownFields } from \"./schemas\";\n\ntype PermissionConfig = {\n allow?: string[];\n deny?: string[];\n};\n\ntype SettingsFile = {\n permissions?: PermissionConfig;\n};\n\nexport async function checkPermissions(projectRoot: string): Promise<React.ReactElement | null> {\n const settingsPath = path.join(projectRoot, CLAUDE_DIR, \"settings.json\");\n const localSettingsPath = path.join(projectRoot, CLAUDE_DIR, \"settings.local.json\");\n\n let permissions: PermissionConfig | undefined;\n\n for (const filePath of [localSettingsPath, settingsPath]) {\n if (await fileExists(filePath)) {\n try {\n const content = await readFileSafe(filePath, MAX_CONFIG_FILE_SIZE);\n const raw = JSON.parse(content);\n if (typeof raw === \"object\" && raw !== null && !Array.isArray(raw)) {\n // Known Claude CLI settings.json fields (permissions is ours; the rest are managed by Claude CLI)\n const EXPECTED_SETTINGS_KEYS = [\n \"permissions\",\n \"enabledPlugins\",\n \"env\",\n \"allowedTools\",\n \"customInstructions\",\n \"defaultModel\",\n ] as const;\n warnUnknownFields(\n raw as Record<string, unknown>,\n EXPECTED_SETTINGS_KEYS,\n `settings file '${filePath}'`,\n );\n }\n const result = settingsFileSchema.safeParse(raw);\n const parsed: SettingsFile = result.success ? (result.data as SettingsFile) : {};\n if (parsed.permissions) {\n permissions = parsed.permissions;\n break;\n }\n } catch {\n warn(`Malformed settings file at '${filePath}' — skipping`);\n }\n }\n }\n\n if (!permissions) {\n return (\n <Box flexDirection=\"column\" borderStyle=\"round\" borderColor={CLI_COLORS.WARNING} padding={1}>\n <Text bold color={CLI_COLORS.WARNING}>\n Permission Notice\n </Text>\n <Text>No permissions configured in .claude/settings.json</Text>\n <Text>Agents will prompt for approval on each tool use.</Text>\n <Text> </Text>\n <Text>For autonomous operation, add to .claude/settings.json:</Text>\n <Text> </Text>\n <Text color=\"dim\">{\"{\"}</Text>\n <Text color=\"dim\">{' \"permissions\": {'}</Text>\n <Text color=\"dim\">{' \"allow\": ['}</Text>\n <Text color=\"dim\">{' \"Read(*)\",'}</Text>\n <Text color=\"dim\">{' \"Bash(git *)\",'}</Text>\n <Text color=\"dim\">{' \"Bash(bun *)\"'}</Text>\n <Text color=\"dim\">{\" ]\"}</Text>\n <Text color=\"dim\">{\" }\"}</Text>\n <Text color=\"dim\">{\"}\"}</Text>\n </Box>\n );\n }\n\n const hasRestrictiveBash = permissions.deny?.some(\n (rule) => rule === \"Bash(*)\" || rule === \"Bash\",\n );\n const hasNoAllows = !permissions.allow || permissions.allow.length === 0;\n\n if (hasRestrictiveBash || hasNoAllows) {\n return (\n <Box flexDirection=\"column\" borderStyle=\"round\" borderColor={CLI_COLORS.WARNING} padding={1}>\n <Text bold color={CLI_COLORS.WARNING}>\n Permission Warnings\n </Text>\n {hasRestrictiveBash && (\n <Text>\n ⚠ Bash is denied in permissions. Some agents require Bash for git, testing, and build\n commands.\n </Text>\n )}\n {hasNoAllows && (\n <Text>⚠ No allow rules configured. Agents will prompt for each tool use.</Text>\n )}\n </Box>\n );\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAEA,SAAS,aAAa;AACtB,SAAS,QAAQ,OAAAA,MAAK,QAAAC,OAAM,cAAc;AAC1C,OAAO,QAAQ;;;ACJf;AAEA,SAAS,MAAM,WAAW;AAC1B,OAAO,UAAU;AAyDX,SACE,KADF;AAzCN,eAAsB,iBAAiB,aAAyD;AAC9F,QAAM,eAA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W,CAAC;AAC1D,QAAI,iBAAiB,aAAa,SAAS,GAAG;AAC5C,WAAK,IAAI,mBAAmB;AAC5B,WAAK,IAAI,KAAK,aAAa,SAAS,EAAE;AACtC,iBAAW,SAAS,cAAc;AAChC,cAAM,cAAc,aAAa,MAAM,EAAE,EAAE;AAC3C,aAAK,IAAI,OAAO,WAAW,GAAG;AAAA,MAChC;AACA,WAAK,IAAI,EAAE;AAAA,IACb;AACA,SAAK,IAAI,qBAAqB;AAC9B,SAAK,IAAI,KAAK,aAAa,SAAS,EAAE;AACtC,eAAW,aAAa,cAAc,UAAU;AAC9C,WAAK,IAAI,OAAO,SAAS,KAAK;AAAA,IAChC;AACA,SAAK,IAAI,EAAE;AACX,SAAK,IAAI,gBAAgB;AACzB,SAAK,IAAI,KAAK,aAAa,UAAU,EAAE;AACvC,SAAK,IAAI,EAAE;AACX,SAAK,IAAI,uCAAuC;AAChD,SAAK,IAAI,iCAAiC;AAC1C,SAAK,IAAI,aAAa,YAAY,gCAAgC;AAClE,SAAK,IAAI,EAAE;AAAA,EACb;AACF;AAUA,eAAsB,iBAAiB,YAA4C;AACjF,QAAM,CAAC,MAAM,MAAM,IAAI,MAAM,QAAQ,IAAI,CAAC,oBAAoB,GAAG,kBAAkB,UAAU,CAAC,CAAC;AAE/F,QAAM,aAAa,QAAQ,QAAQ,QAAQ,UAAU;AACrD,QAAM,aAAa,MAAM,cAAc;AACvC,QAAM,OACJ,MAAM,SAAS,QAAQ,QAAQ,SAAS,kBAAkB,OAAO,OAAO,MAAM,IAAI;AACpF,QAAM,SAAS,QAAQ,QAAQ;AAE/B,SAAO,EAAE,YAAY,YAAY,MAAM,OAAO;AAChD;","names":["Box","Text","jsx","jsxs","Box","Text","result"]}
@@ -350,4 +350,4 @@ var SkillSearch = ({
350
350
  export {
351
351
  SkillSearch
352
352
  };
353
- //# sourceMappingURL=chunk-BV2MIQ3O.js.map
353
+ //# sourceMappingURL=chunk-I5AZKNNL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/components/skill-search/skill-search.tsx","../src/cli/components/hooks/use-filtered-results.ts"],"sourcesContent":["import React, { useState, useCallback } from \"react\";\nimport { Box, Text, useApp, useInput } from \"ink\";\nimport { ThemeProvider } from \"@inkjs/ui\";\nimport { cliTheme } from \"../themes/default.js\";\nimport type { SkillId, ResolvedSkill } from \"../../types/index.js\";\nimport { CLI_COLORS, UI_SYMBOLS, UI_LAYOUT } from \"../../consts.js\";\nimport {\n HOTKEY_COPY_LINK,\n KEY_LABEL_ENTER,\n KEY_LABEL_ESC,\n KEY_LABEL_SPACE,\n KEY_LABEL_VIM_VERT,\n isHotkey,\n} from \"../wizard/hotkeys.js\";\nimport { useTextInput } from \"../hooks/use-text-input.js\";\nimport { useFilteredResults } from \"../hooks/use-filtered-results.js\";\nimport { truncateText } from \"../../utils/string.js\";\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 SkillSearchResult = {\n selectedSkills: SourcedSkill[];\n cancelled: boolean;\n};\n\nexport type SkillSearchProps = {\n skills: SourcedSkill[];\n sourceCount: number;\n initialQuery?: string;\n onComplete: (result: SkillSearchResult) => void;\n onCancel: () => void;\n};\n\nconst {\n MAX_VISIBLE_RESULTS,\n DESCRIPTION_WIDTH,\n COPIED_MESSAGE_TIMEOUT_MS,\n FALLBACK_MESSAGE_TIMEOUT_MS,\n} = UI_LAYOUT;\nconst { CHECKBOX_CHECKED, CHECKBOX_UNCHECKED } = UI_SYMBOLS;\n\nfunction matchesQuery(skill: SourcedSkill, query: string): boolean {\n if (!query.trim()) return true;\n\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 return skill.sourceName.toLowerCase().includes(lowerQuery);\n}\n\ntype HeaderProps = {\n sourceCount: number;\n};\n\nconst Header: React.FC<HeaderProps> = ({ sourceCount }) => {\n return (\n <Box\n flexDirection=\"row\"\n justifyContent=\"space-between\"\n borderStyle=\"single\"\n borderBottom={false}\n borderLeft={false}\n borderRight={false}\n paddingX={1}\n >\n <Text bold color={CLI_COLORS.PRIMARY}>\n Search Skills\n </Text>\n <Text dimColor>\n {sourceCount} source{sourceCount !== 1 ? \"s\" : \"\"}\n </Text>\n </Box>\n );\n};\n\ntype SearchInputProps = {\n value: string;\n};\n\nconst SearchInput: React.FC<SearchInputProps> = ({ value }) => {\n return (\n <Box paddingX={1} paddingY={1}>\n <Text color={CLI_COLORS.FOCUS}>{\">\"} </Text>\n <Text>{value}</Text>\n <Text color={CLI_COLORS.FOCUS}>_</Text>\n </Box>\n );\n};\n\ntype ResultItemProps = {\n skill: SourcedSkill;\n isSelected: boolean;\n isFocused: boolean;\n};\n\nconst ResultItem: React.FC<ResultItemProps> = ({ skill, isSelected, isFocused }) => {\n const checkbox = isSelected ? CHECKBOX_CHECKED : CHECKBOX_UNCHECKED;\n const displayName = skill.displayName;\n return (\n <Box flexDirection=\"row\" gap={1}>\n <Text\n color={isFocused ? CLI_COLORS.FOCUS : isSelected ? CLI_COLORS.SUCCESS : undefined}\n bold={isFocused}\n backgroundColor={isFocused ? \"#333333\" : undefined}\n >\n {\" \"}\n {checkbox}{\" \"}\n </Text>\n <Box width={14}>\n <Text dimColor>{truncateText(skill.sourceName, 12)}</Text>\n </Box>\n <Box width={24}>\n <Text color={isFocused ? CLI_COLORS.FOCUS : undefined} bold={isFocused || isSelected}>\n {truncateText(displayName, 22)}\n </Text>\n </Box>\n <Text dimColor>{truncateText(skill.description, DESCRIPTION_WIDTH)}</Text>\n </Box>\n );\n};\n\ntype ResultsListProps = {\n results: SourcedSkill[];\n selectedIds: Set<SkillId>;\n focusedIndex: number;\n scrollOffset: number;\n};\n\nconst ResultsList: React.FC<ResultsListProps> = ({\n results,\n selectedIds,\n focusedIndex,\n scrollOffset,\n}) => {\n const visibleResults = results.slice(scrollOffset, scrollOffset + MAX_VISIBLE_RESULTS);\n\n if (results.length === 0) {\n return (\n <Box paddingX={1} paddingY={1}>\n <Text dimColor>No skills found matching your search.</Text>\n </Box>\n );\n }\n\n return (\n <Box\n flexDirection=\"column\"\n borderStyle=\"single\"\n borderTop={false}\n borderBottom={false}\n paddingX={1}\n >\n {visibleResults.map((skill, index) => {\n const actualIndex = scrollOffset + index;\n return (\n <ResultItem\n key={skill.id}\n skill={skill}\n isSelected={selectedIds.has(skill.id)}\n isFocused={actualIndex === focusedIndex}\n />\n );\n })}\n </Box>\n );\n};\n\ntype StatusBarProps = {\n resultCount: number;\n selectedCount: number;\n};\n\nconst StatusBar: React.FC<StatusBarProps> = ({ resultCount, selectedCount }) => {\n return (\n <Box paddingX={1}>\n <Text dimColor>\n {resultCount} result{resultCount !== 1 ? \"s\" : \"\"}\n {selectedCount > 0 && <Text color={CLI_COLORS.SUCCESS}> | {selectedCount} selected</Text>}\n </Text>\n </Box>\n );\n};\n\ntype FooterProps = {\n hasSelection: boolean;\n};\n\nconst Footer: React.FC<FooterProps> = ({ hasSelection }) => {\n return (\n <Box\n flexDirection=\"row\"\n justifyContent=\"center\"\n gap={2}\n borderStyle=\"single\"\n borderTop={false}\n borderLeft={false}\n borderRight={false}\n paddingX={1}\n marginTop={1}\n >\n <Text dimColor>\n <Text color={CLI_COLORS.UNFOCUSED}>{KEY_LABEL_VIM_VERT}</Text> navigate\n </Text>\n <Text dimColor>\n <Text color={CLI_COLORS.UNFOCUSED}>{KEY_LABEL_SPACE}</Text> select\n </Text>\n {hasSelection && (\n <Text dimColor>\n <Text color={CLI_COLORS.SUCCESS}>{KEY_LABEL_ENTER}</Text> import\n </Text>\n )}\n <Text dimColor>\n <Text color={CLI_COLORS.UNFOCUSED}>{HOTKEY_COPY_LINK.label}</Text> copy link\n </Text>\n <Text dimColor>\n <Text color={CLI_COLORS.WARNING}>{KEY_LABEL_ESC}</Text> cancel\n </Text>\n </Box>\n );\n};\n\nexport const SkillSearch: React.FC<SkillSearchProps> = ({\n skills,\n sourceCount,\n initialQuery = \"\",\n onComplete,\n onCancel,\n}) => {\n const { exit } = useApp();\n\n const { value: query, handleInput: handleTextInput } = useTextInput(initialQuery);\n const [selectedIds, setSelectedIds] = useState<Set<SkillId>>(new Set());\n const [copiedMessage, setCopiedMessage] = useState<string | null>(null);\n\n const {\n filteredResults,\n safeFocusedIndex,\n focusedItem: focusedSkill,\n scrollOffset,\n moveUp,\n moveDown,\n } = useFilteredResults({\n items: skills,\n query,\n filterFn: matchesQuery,\n maxVisible: MAX_VISIBLE_RESULTS,\n });\n\n const toggleSelection = useCallback((skillId: SkillId) => {\n setSelectedIds((prev) => {\n const next = new Set(prev);\n if (next.has(skillId)) {\n next.delete(skillId);\n } else {\n next.add(skillId);\n }\n return next;\n });\n }, []);\n\n const copySkillLink = useCallback(async (skill: SourcedSkill) => {\n const link = skill.sourceUrl ? `${skill.sourceUrl}/${skill.id}` : skill.id;\n\n try {\n // OSC 52 terminal clipboard escape sequence\n const encoded = Buffer.from(link).toString(\"base64\");\n process.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n setCopiedMessage(`Copied: ${link}`);\n setTimeout(() => setCopiedMessage(null), COPIED_MESSAGE_TIMEOUT_MS);\n } catch {\n setCopiedMessage(`Link: ${link}`);\n setTimeout(() => setCopiedMessage(null), FALLBACK_MESSAGE_TIMEOUT_MS);\n }\n }, []);\n\n useInput((input, key) => {\n if (key.escape) {\n onCancel();\n exit();\n return;\n }\n\n if (key.return) {\n if (selectedIds.size > 0) {\n const selectedSkills = filteredResults.filter((s) => selectedIds.has(s.id));\n onComplete({\n selectedSkills,\n cancelled: false,\n });\n exit();\n }\n return;\n }\n\n if (input === \" \" && focusedSkill) {\n toggleSelection(focusedSkill.id);\n return;\n }\n\n if (isHotkey(input, HOTKEY_COPY_LINK) && focusedSkill) {\n void copySkillLink(focusedSkill);\n return;\n }\n\n const isUp = key.upArrow || input === \"k\";\n const isDown = key.downArrow || input === \"j\";\n\n if (isUp) {\n moveUp();\n }\n\n if (isDown) {\n moveDown();\n }\n\n handleTextInput(input, key);\n });\n\n return (\n <ThemeProvider theme={cliTheme}>\n <Box flexDirection=\"column\">\n <Header sourceCount={sourceCount} />\n <SearchInput value={query} />\n <ResultsList\n results={filteredResults}\n selectedIds={selectedIds}\n focusedIndex={safeFocusedIndex}\n scrollOffset={scrollOffset}\n />\n <StatusBar resultCount={filteredResults.length} selectedCount={selectedIds.size} />\n {copiedMessage && (\n <Box paddingX={1}>\n <Text color={CLI_COLORS.SUCCESS}>{copiedMessage}</Text>\n </Box>\n )}\n <Footer hasSelection={selectedIds.size > 0} />\n </Box>\n </ThemeProvider>\n );\n};\n","import { useState, useMemo, useEffect, useCallback, useRef } from \"react\";\n\ntype UseFilteredResultsOptions<T> = {\n /** Items to filter */\n items: T[];\n /** Current search query */\n query: string;\n /** Filter predicate — returns true if item matches the query */\n filterFn: (item: T, query: string) => boolean;\n /** Number of visible rows in the scrollable viewport */\n maxVisible: number;\n};\n\ntype UseFilteredResultsResult<T> = {\n /** Items that pass the filter */\n filteredResults: T[];\n /** Index clamped to valid range */\n safeFocusedIndex: number;\n /** The item at safeFocusedIndex, or undefined when empty */\n focusedItem: T | undefined;\n /** First visible row offset for windowed rendering */\n scrollOffset: number;\n /** Move focus up one row (clamped, adjusts scroll) */\n moveUp: () => void;\n /** Move focus down one row (clamped, adjusts scroll) */\n moveDown: () => void;\n};\n\n/**\n * Manages filtered list state: query-based filtering, focus tracking,\n * and scroll-offset synchronisation for windowed rendering.\n * Focus and scroll reset automatically when the query changes.\n */\nexport function useFilteredResults<T>({\n items,\n query,\n filterFn,\n maxVisible,\n}: UseFilteredResultsOptions<T>): UseFilteredResultsResult<T> {\n const [focusedIndex, setFocusedIndex] = useState(0);\n const [scrollOffset, setScrollOffset] = useState(0);\n\n useEffect(() => {\n setFocusedIndex(0);\n setScrollOffset(0);\n }, [query]);\n\n const filteredResults = useMemo(() => {\n return items.filter((item) => filterFn(item, query));\n }, [items, query, filterFn]);\n\n const safeFocusedIndex = Math.min(focusedIndex, Math.max(0, filteredResults.length - 1));\n const focusedItem = filteredResults[safeFocusedIndex] as T | undefined;\n\n // Refs for stable callback access (matches use-keyboard-navigation pattern)\n const safeFocusedIndexRef = useRef(safeFocusedIndex);\n const scrollOffsetRef = useRef(scrollOffset);\n const resultCountRef = useRef(filteredResults.length);\n\n useEffect(() => {\n safeFocusedIndexRef.current = safeFocusedIndex;\n }, [safeFocusedIndex]);\n\n useEffect(() => {\n scrollOffsetRef.current = scrollOffset;\n }, [scrollOffset]);\n\n useEffect(() => {\n resultCountRef.current = filteredResults.length;\n }, [filteredResults.length]);\n\n const moveUp = useCallback(() => {\n const current = safeFocusedIndexRef.current;\n if (current <= 0) return;\n const newIndex = current - 1;\n setFocusedIndex(newIndex);\n if (newIndex < scrollOffsetRef.current) {\n setScrollOffset(newIndex);\n }\n }, []);\n\n const moveDown = useCallback(() => {\n const current = safeFocusedIndexRef.current;\n if (current >= resultCountRef.current - 1) return;\n const newIndex = current + 1;\n setFocusedIndex(newIndex);\n if (newIndex >= scrollOffsetRef.current + maxVisible) {\n setScrollOffset(newIndex - maxVisible + 1);\n }\n }, [maxVisible]);\n\n return {\n filteredResults,\n safeFocusedIndex,\n focusedItem,\n scrollOffset,\n moveUp,\n moveDown,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAgB,YAAAA,WAAU,eAAAC,oBAAmB;AAC7C,SAAS,KAAK,MAAM,QAAQ,gBAAgB;AAC5C,SAAS,qBAAqB;;;ACF9B;AAAA,SAAS,UAAU,SAAS,WAAW,aAAa,cAAc;AAiC3D,SAAS,mBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8D;AAC5D,QAAM,CAAC,cAAc,eAAe,IAA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