@agents-inc/cli 0.77.0 → 0.79.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.
- package/CHANGELOG.md +21 -0
- package/dist/{chunk-ZIZFTSQY.js → chunk-7HGMFJ4Y.js} +2 -2
- package/dist/{chunk-R6QNVMN5.js → chunk-B4C2S5LP.js} +11 -11
- package/dist/{chunk-R6QNVMN5.js.map → chunk-B4C2S5LP.js.map} +1 -1
- package/dist/{chunk-B66E255O.js → chunk-D4T3HHE7.js} +3 -3
- package/dist/chunk-D4T3HHE7.js.map +1 -0
- package/dist/{chunk-KMLJCO5H.js → chunk-F4IZ3UAS.js} +15 -21
- package/dist/chunk-F4IZ3UAS.js.map +1 -0
- package/dist/{chunk-XU6N3OIS.js → chunk-HANGA633.js} +2 -6
- package/dist/{chunk-XU6N3OIS.js.map → chunk-HANGA633.js.map} +1 -1
- package/dist/{chunk-2I5SXGXR.js → chunk-KQDGLEBF.js} +80 -5
- package/dist/chunk-KQDGLEBF.js.map +1 -0
- package/dist/{chunk-G3YSDQJ2.js → chunk-KVRR4PEJ.js} +46 -37
- package/dist/chunk-KVRR4PEJ.js.map +1 -0
- package/dist/{chunk-J5OOAKB5.js → chunk-LVBRC2CP.js} +1 -5
- package/dist/chunk-LVBRC2CP.js.map +1 -0
- package/dist/chunk-N2XGUAJU.js +34 -0
- package/dist/{chunk-KB57OPUL.js.map → chunk-N2XGUAJU.js.map} +1 -1
- package/dist/{chunk-CY23HPDE.js → chunk-N34D3ROY.js} +10 -11
- package/dist/chunk-N34D3ROY.js.map +1 -0
- package/dist/{chunk-PDYKGJGR.js → chunk-NKLNT7N7.js} +3 -20
- package/dist/chunk-NKLNT7N7.js.map +1 -0
- package/dist/{chunk-CZLXZ75E.js → chunk-OIHZ2YH3.js} +107 -69
- package/dist/chunk-OIHZ2YH3.js.map +1 -0
- package/dist/{chunk-SGKNE6EJ.js → chunk-OOWNDQCG.js} +2 -2
- package/dist/{chunk-WMTYOK4E.js → chunk-OTMIGYBB.js} +48 -6
- package/dist/chunk-OTMIGYBB.js.map +1 -0
- package/dist/chunk-PZERKWE2.js +114 -0
- package/dist/chunk-PZERKWE2.js.map +1 -0
- package/dist/{chunk-N4KD5PBX.js → chunk-Q755X6QF.js} +2 -2
- package/dist/{chunk-AQ5KP4YW.js → chunk-QD3GQ2CH.js} +3 -3
- package/dist/{chunk-ERHTXNIF.js → chunk-RU5XLS5Q.js} +1 -5
- package/dist/{chunk-ERHTXNIF.js.map → chunk-RU5XLS5Q.js.map} +1 -1
- package/dist/{chunk-UZHD4DBD.js → chunk-SJNUTUSJ.js} +2 -2
- package/dist/{chunk-5DDHCCEB.js → chunk-VDVLM3KB.js} +42 -4
- package/dist/chunk-VDVLM3KB.js.map +1 -0
- package/dist/{chunk-CTZ4GEAD.js → chunk-W46L2PXK.js} +17 -8
- package/dist/chunk-W46L2PXK.js.map +1 -0
- package/dist/{chunk-A6XMJT2Q.js → chunk-YFHVP3VA.js} +3 -10
- package/dist/chunk-YFHVP3VA.js.map +1 -0
- package/dist/commands/build/plugins.js +2 -2
- package/dist/commands/build/stack.js +2 -2
- package/dist/commands/compile.js +32 -16
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/config/index.js +2 -2
- package/dist/commands/config/path.js +1 -1
- package/dist/commands/config/show.js +2 -2
- package/dist/commands/diff.js +29 -9
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +18 -6
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +37 -27
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +1 -1
- package/dist/commands/import/skill.js +1 -1
- package/dist/commands/info.js +1 -1
- package/dist/commands/init.js +18 -18
- package/dist/commands/list.js +1 -1
- package/dist/commands/new/agent.js +2 -2
- package/dist/commands/new/marketplace.js +2 -2
- package/dist/commands/new/skill.js +2 -2
- package/dist/commands/outdated.js +12 -4
- package/dist/commands/outdated.js.map +1 -1
- package/dist/commands/search.js +1 -1
- package/dist/commands/uninstall.js +9 -21
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +20 -10
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.js +1 -1
- package/dist/components/wizard/category-grid.js +1 -1
- package/dist/components/wizard/category-grid.test.js +3 -3
- package/dist/components/wizard/checkbox-grid.js +1 -2
- package/dist/components/wizard/checkbox-grid.test.js +2 -4
- package/dist/components/wizard/checkbox-grid.test.js.map +1 -1
- package/dist/components/wizard/domain-selection.js +4 -5
- package/dist/components/wizard/source-grid.js +1 -1
- package/dist/components/wizard/source-grid.test.js +3 -3
- package/dist/components/wizard/stack-selection.js +3 -3
- package/dist/components/wizard/stats-panel.js +12 -0
- package/dist/components/wizard/step-agents.js +3 -4
- package/dist/components/wizard/step-agents.test.js +7 -6
- package/dist/components/wizard/step-agents.test.js.map +1 -1
- package/dist/components/wizard/step-build.js +5 -6
- package/dist/components/wizard/step-build.test.js +23 -23
- package/dist/components/wizard/step-build.test.js.map +1 -1
- package/dist/components/wizard/step-confirm.js +1 -3
- package/dist/components/wizard/step-confirm.test.js +17 -16
- package/dist/components/wizard/step-confirm.test.js.map +1 -1
- package/dist/components/wizard/step-refine.js +1 -2
- package/dist/components/wizard/step-refine.test.js +1 -2
- package/dist/components/wizard/step-refine.test.js.map +1 -1
- package/dist/components/wizard/step-settings.js +2 -3
- package/dist/components/wizard/step-settings.test.js +8 -9
- package/dist/components/wizard/step-settings.test.js.map +1 -1
- package/dist/components/wizard/step-sources.js +4 -5
- package/dist/components/wizard/step-sources.test.js +7 -9
- package/dist/components/wizard/step-sources.test.js.map +1 -1
- package/dist/components/wizard/step-stack.js +6 -7
- package/dist/components/wizard/step-stack.test.js +16 -15
- package/dist/components/wizard/step-stack.test.js.map +1 -1
- package/dist/components/wizard/view-title.js +21 -3
- package/dist/components/wizard/view-title.js.map +1 -1
- package/dist/components/wizard/wizard-layout.js +5 -4
- package/dist/components/wizard/wizard-tabs.js +1 -1
- package/dist/components/wizard/wizard-tabs.test.js +1 -1
- package/dist/components/wizard/wizard.js +17 -17
- package/dist/hooks/init.js +18 -18
- package/dist/{source-loader-H3QLG5AE.js → source-loader-D3VIG3GM.js} +2 -2
- package/dist/{source-manager-ZDBUHGIR.js → source-manager-FPYFJRR7.js} +2 -2
- package/dist/source-manager-FPYFJRR7.js.map +1 -0
- package/dist/stores/wizard-store.js +2 -2
- package/dist/stores/wizard-store.test.js +4 -4
- package/dist/stores/wizard-store.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2I5SXGXR.js.map +0 -1
- package/dist/chunk-5DDHCCEB.js.map +0 -1
- package/dist/chunk-A6XMJT2Q.js.map +0 -1
- package/dist/chunk-B66E255O.js.map +0 -1
- package/dist/chunk-CTZ4GEAD.js.map +0 -1
- package/dist/chunk-CY23HPDE.js.map +0 -1
- package/dist/chunk-CZLXZ75E.js.map +0 -1
- package/dist/chunk-G3YSDQJ2.js.map +0 -1
- package/dist/chunk-J5OOAKB5.js.map +0 -1
- package/dist/chunk-JNQKCZA3.js +0 -28
- package/dist/chunk-JNQKCZA3.js.map +0 -1
- package/dist/chunk-KB57OPUL.js +0 -40
- package/dist/chunk-KMLJCO5H.js.map +0 -1
- package/dist/chunk-PDYKGJGR.js.map +0 -1
- package/dist/chunk-WMTYOK4E.js.map +0 -1
- /package/dist/{chunk-ZIZFTSQY.js.map → chunk-7HGMFJ4Y.js.map} +0 -0
- /package/dist/{chunk-SGKNE6EJ.js.map → chunk-OOWNDQCG.js.map} +0 -0
- /package/dist/{chunk-N4KD5PBX.js.map → chunk-Q755X6QF.js.map} +0 -0
- /package/dist/{chunk-AQ5KP4YW.js.map → chunk-QD3GQ2CH.js.map} +0 -0
- /package/dist/{chunk-UZHD4DBD.js.map → chunk-SJNUTUSJ.js.map} +0 -0
- /package/dist/{source-loader-H3QLG5AE.js.map → components/wizard/stats-panel.js.map} +0 -0
- /package/dist/{source-manager-ZDBUHGIR.js.map → source-loader-D3VIG3GM.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/components/wizard/category-grid.tsx","../src/cli/components/hooks/use-category-grid-input.ts"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\n\nimport { Box, Text } from \"ink\";\n\nimport { CLI_COLORS } from \"../../consts.js\";\nimport { getSkillById } from \"../../lib/matrix/matrix-provider.js\";\nimport type { Category, OptionState, SkillId } from \"../../types/index.js\";\nimport { isSectionLocked, useCategoryGridInput } from \"../hooks/use-category-grid-input.js\";\nimport { useFocusedListItem } from \"../hooks/use-focused-list-item.js\";\nimport { useSectionScroll } from \"../hooks/use-section-scroll.js\";\n\nexport type CategoryOption = {\n id: SkillId;\n state: OptionState;\n selected: boolean;\n local?: boolean;\n installed?: boolean;\n scope?: \"project\" | \"global\";\n /** True when selected but has unmet dependency requirements (shown dimmed) */\n hasUnmetRequirements?: boolean;\n /** Explains unmet requirements (shown in label when D pressed) */\n unmetRequirementsReason?: string;\n /** Display name of the skill that requires this one (e.g. \"Next.js\") */\n requiredBy?: string;\n};\n\nexport type CategoryRow = {\n id: Category;\n displayName: string;\n required: boolean;\n exclusive: boolean;\n options: CategoryOption[];\n};\n\nexport type CategoryGridProps = {\n categories: CategoryRow[];\n /** Available height in terminal lines for the scrollable viewport. 0 = no constraint. */\n availableHeight?: number;\n showLabels: boolean;\n onToggle: (categoryId: Category, technologyId: SkillId) => void;\n onToggleLabels: () => void;\n onToggleFilterIncompatible?: () => void;\n /** Optional initial focus row (default: 0). Use with React `key` to reset. */\n defaultFocusedRow?: number;\n /** Optional initial focus col (default: 0). Use with React `key` to reset. */\n defaultFocusedCol?: number;\n /** Optional callback fired whenever the focused position changes */\n onFocusChange?: (row: number, col: number) => void;\n /** Optional callback fired with the resolved SkillId of the focused cell */\n onFocusedSkillChange?: (skillId: SkillId | null) => void;\n};\n\nconst SYMBOL_REQUIRED = \"*\";\n\nconst findNextValidOption = (\n options: CategoryOption[],\n currentIndex: number,\n direction: 1 | -1,\n wrap = true,\n): number => {\n const length = options.length;\n if (length === 0) return currentIndex;\n\n let index = currentIndex + direction;\n\n if (wrap) {\n if (index < 0) index = length - 1;\n if (index >= length) index = 0;\n } else {\n if (index < 0) index = 0;\n if (index >= length) index = length - 1;\n }\n\n return index;\n};\n\ntype SkillTagProps = {\n option: CategoryOption;\n isFocused: boolean;\n isLocked: boolean;\n showLabels: boolean;\n};\n\nconst getCompatibilityLabel = (option: CategoryOption): string | null => {\n if (option.selected && option.hasUnmetRequirements && option.unmetRequirementsReason) {\n return `(${option.unmetRequirementsReason})`;\n }\n if (option.selected) return null;\n if (option.requiredBy) return `(required by ${option.requiredBy})`;\n if (option.state.status === \"incompatible\") return \"(incompatible)\";\n if (option.state.status === \"recommended\") return \"(recommended)\";\n if (option.state.status === \"discouraged\") return \"(discouraged)\";\n return null;\n};\n\nconst SkillTag: React.FC<SkillTagProps> = ({ option, isFocused, isLocked, showLabels }) => {\n const getTextColor = (): string => {\n if (option.selected) return CLI_COLORS.PRIMARY;\n if (option.state.status === \"incompatible\") return CLI_COLORS.ERROR;\n if (option.state.status === \"recommended\") return CLI_COLORS.UNFOCUSED;\n if (option.state.status === \"discouraged\") return CLI_COLORS.WARNING;\n\n return CLI_COLORS.NEUTRAL;\n };\n\n const getStateBorderColor = (): string => {\n if (option.selected) return CLI_COLORS.PRIMARY;\n if (option.state.status === \"incompatible\") return CLI_COLORS.ERROR;\n if (option.state.status === \"recommended\") return CLI_COLORS.UNFOCUSED;\n if (option.state.status === \"discouraged\") return CLI_COLORS.WARNING;\n return CLI_COLORS.UNFOCUSED;\n };\n\n const textColor = getTextColor();\n const hasRequiredBy = option.selected && !!option.requiredBy;\n const hasUnmetDeps = option.selected && !!option.hasUnmetRequirements;\n const compatibilityLabel = hasRequiredBy\n ? getCompatibilityLabel(option)\n : hasUnmetDeps\n ? getCompatibilityLabel(option)\n : showLabels && isFocused\n ? getCompatibilityLabel(option)\n : null;\n\n return (\n <Box\n marginRight={1}\n borderColor={isFocused ? getStateBorderColor() : CLI_COLORS.NEUTRAL}\n borderStyle=\"single\"\n flexShrink={0}\n paddingLeft={1}\n >\n <>\n <Text />\n {option.scope && (\n <>\n <Text\n color={option.scope === \"global\" ? CLI_COLORS.WARNING : \"#eee\"}\n backgroundColor={\"#383838\"}\n >\n {option.scope === \"global\" ? \" G \" : \" P \"}\n </Text>\n <Text> </Text>\n </>\n )}\n <Text\n color={textColor}\n bold\n dimColor={\n (option.selected && !!option.hasUnmetRequirements) ||\n (option.selected && !!option.requiredBy)\n }\n >\n {getSkillById(option.id).displayName}{\" \"}\n </Text>\n {compatibilityLabel && (\n <Text color={textColor} dimColor>\n {compatibilityLabel}{\" \"}\n </Text>\n )}\n </>\n </Box>\n );\n};\n\ntype CategorySectionProps = {\n isFirst: boolean;\n category: CategoryRow;\n options: CategoryOption[];\n isLocked: boolean;\n isFocused: boolean;\n focusedOptionIndex: number;\n showLabels: boolean;\n};\n\nconst CategorySection: React.FC<CategorySectionProps> = ({\n isFirst,\n category,\n options,\n isLocked,\n isFocused,\n focusedOptionIndex,\n showLabels,\n}) => {\n const selectedCount = options.filter((o) => o.selected).length;\n\n const selectionCounter = category.exclusive ? `(${selectedCount} of 1)` : null;\n\n return (\n <Box flexDirection=\"column\" marginTop={isFirst ? 0 : 1}>\n <Box flexDirection=\"row\">\n {isFocused ? (\n <Text color={CLI_COLORS.WHITE} backgroundColor=\"#383838\">\n {` ${category.displayName}${category.required ? ` ${SYMBOL_REQUIRED}` : \"\"}${selectionCounter ? ` ${selectionCounter}` : \"\"} `}\n </Text>\n ) : (\n <>\n <Text color=\"gray\">{category.displayName}</Text>\n {category.required && <Text color=\"gray\"> {SYMBOL_REQUIRED}</Text>}\n {selectionCounter && <Text dimColor> {selectionCounter}</Text>}\n </>\n )}\n </Box>\n\n <Box flexDirection=\"row\" flexWrap=\"wrap\" marginTop={0}>\n {options.map((option, index) => (\n <SkillTag\n key={option.id}\n option={option}\n isFocused={isFocused && index === focusedOptionIndex && !isLocked}\n isLocked={isLocked}\n showLabels={showLabels}\n />\n ))}\n </Box>\n </Box>\n );\n};\n\ntype ProcessedCategory = CategoryRow & { sortedOptions: CategoryOption[] };\n\nexport const CategoryGrid: React.FC<CategoryGridProps> = ({\n categories,\n availableHeight = 0,\n showLabels,\n onToggle,\n onToggleLabels,\n onToggleFilterIncompatible,\n defaultFocusedRow = 0,\n defaultFocusedCol = 0,\n onFocusChange,\n onFocusedSkillChange,\n}) => {\n const processedCategories = useMemo(\n () => categories.map((category) => ({ ...category, sortedOptions: category.options })),\n [categories],\n );\n\n const getColCount = useCallback(\n (row: number): number => processedCategories[row]?.sortedOptions.length ?? 0,\n [processedCategories],\n );\n\n const isRowLocked = useCallback(\n (row: number): boolean => {\n const cat = processedCategories[row];\n return cat ? isSectionLocked(cat.id, categories) : false;\n },\n [processedCategories, categories],\n );\n\n const findValidCol = useCallback(\n (row: number, currentCol: number, direction: 1 | -1): number => {\n const options = processedCategories[row]?.sortedOptions || [];\n const catId = processedCategories[row]?.id;\n if (catId && isSectionLocked(catId, categories)) return currentCol;\n return findNextValidOption(options, currentCol, direction, true);\n },\n [processedCategories, categories],\n );\n\n const handleFocusChange = useCallback(\n (row: number, col: number) => {\n if (showLabels) onToggleLabels();\n onFocusChange?.(row, col);\n const skill = processedCategories[row]?.sortedOptions[col];\n onFocusedSkillChange?.(skill?.id ?? null);\n },\n [showLabels, onToggleLabels, onFocusChange, processedCategories, onFocusedSkillChange],\n );\n\n const { focusedRow, focusedCol, setFocused, moveFocus } = useFocusedListItem(\n processedCategories.length,\n getColCount,\n {\n wrap: true,\n isRowLocked,\n findValidCol,\n onChange: handleFocusChange,\n initialRow: defaultFocusedRow,\n initialCol: defaultFocusedCol,\n },\n );\n\n const mountedRef = useRef(false);\n useEffect(() => {\n if (!mountedRef.current) {\n mountedRef.current = true;\n const skill = processedCategories[defaultFocusedRow]?.sortedOptions[defaultFocusedCol];\n onFocusedSkillChange?.(skill?.id ?? null);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps -- fire once on mount to notify parent of initial focus\n\n useCategoryGridInput({\n processedCategories,\n categories,\n focusedRow,\n focusedCol,\n setFocused,\n moveFocus,\n onToggle,\n onToggleLabels,\n onToggleFilterIncompatible,\n });\n\n const { setSectionRef, scrollEnabled, scrollTopPx } = useSectionScroll({\n sectionCount: processedCategories.length,\n focusedIndex: focusedRow,\n availableHeight,\n });\n\n if (categories.length === 0) {\n return (\n <Box flexDirection=\"column\">\n <Text dimColor>No categories to display.</Text>\n </Box>\n );\n }\n\n const noShrink = scrollEnabled ? { flexShrink: 0 } : {};\n\n const sectionElements = processedCategories.map((category, index) => {\n const isLocked = isSectionLocked(category.id, categories);\n\n return (\n <Box key={category.id} ref={(el) => setSectionRef(index, el)} {...noShrink}>\n <CategorySection\n category={category}\n options={category.sortedOptions}\n isLocked={isLocked}\n isFocused={index === focusedRow}\n focusedOptionIndex={focusedCol}\n showLabels={showLabels}\n isFirst={index === 0}\n />\n </Box>\n );\n });\n\n return (\n <Box\n flexDirection=\"column\"\n {...(scrollEnabled\n ? { height: availableHeight, overflow: \"hidden\" as const }\n : { flexGrow: 1 })}\n >\n <Box flexDirection=\"column\" marginTop={scrollTopPx > 0 ? -scrollTopPx : 0} {...noShrink}>\n {sectionElements}\n </Box>\n </Box>\n );\n};\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useInput } from \"ink\";\n\nimport type { Category, SkillId } from \"../../types/index.js\";\nimport type { CategoryOption, CategoryRow } from \"../wizard/category-grid.js\";\nimport { HOTKEY_FILTER_INCOMPATIBLE, HOTKEY_TOGGLE_LABELS, isHotkey } from \"../wizard/hotkeys.js\";\n\nconst FRAMEWORK_CATEGORY_ID = \"web-framework\";\n\n// No sections are locked — users can freely navigate and select any skill\nexport const isSectionLocked = (_categoryId: Category, _categories: CategoryRow[]): boolean => {\n return false;\n};\n\nexport const findValidStartColumn = (_options: CategoryOption[]): number => {\n return 0;\n};\n\n/** Find next unlocked section index (wrapping, direction: forward) */\nexport const findNextUnlockedIndex = (\n processed: { id: Category; sortedOptions: CategoryOption[] }[],\n currentIndex: number,\n allCategories: CategoryRow[],\n): number => {\n const length = processed.length;\n if (length === 0) return currentIndex;\n\n let index = currentIndex;\n let attempts = 0;\n\n while (attempts < length) {\n index += 1;\n if (index >= length) index = 0;\n\n const category = processed[index];\n if (category && !isSectionLocked(category.id, allCategories)) {\n return index;\n }\n\n attempts++;\n }\n\n return currentIndex;\n};\n\ntype ProcessedCategory = CategoryRow & { sortedOptions: CategoryOption[] };\n\ntype UseCategoryGridInputOptions = {\n processedCategories: ProcessedCategory[];\n categories: CategoryRow[];\n focusedRow: number;\n focusedCol: number;\n setFocused: (row: number, col: number) => void;\n moveFocus: (direction: \"up\" | \"down\" | \"left\" | \"right\") => void;\n onToggle: (categoryId: Category, technologyId: SkillId) => void;\n onToggleLabels: () => void;\n onToggleFilterIncompatible?: () => void;\n};\n\nexport function useCategoryGridInput({\n processedCategories,\n categories,\n focusedRow,\n focusedCol,\n setFocused,\n moveFocus,\n onToggle,\n onToggleLabels,\n onToggleFilterIncompatible,\n}: UseCategoryGridInputOptions): void {\n const currentRow = processedCategories[focusedRow];\n const currentOptions = currentRow?.sortedOptions || [];\n const currentLocked = currentRow ? isSectionLocked(currentRow.id, categories) : false;\n\n // Adjust column when current row's options change externally (e.g. option becomes disabled)\n useEffect(() => {\n if (!currentRow) return;\n\n const maxCol = currentOptions.length - 1;\n if (focusedCol > maxCol) {\n const newCol = Math.max(0, maxCol);\n setFocused(focusedRow, newCol);\n }\n }, [focusedRow, currentOptions, focusedCol, setFocused, currentRow]);\n\n // Bounce off locked sections when a section becomes locked (e.g. framework deselected)\n useEffect(() => {\n if (currentRow && currentLocked) {\n const nextUnlocked = findNextUnlockedIndex(processedCategories, focusedRow, categories);\n if (nextUnlocked !== focusedRow) {\n const newRowOptions = processedCategories[nextUnlocked]?.sortedOptions || [];\n const newCol = findValidStartColumn(newRowOptions);\n setFocused(nextUnlocked, newCol);\n }\n }\n }, [currentRow, currentLocked, focusedRow, processedCategories, categories, setFocused]);\n\n // Store the latest handler in a ref so that the useInput effect never needs to\n // re-register on the event emitter. This avoids a stale-closure race condition\n // where, after a domain switch (CategoryGrid remount via key={activeDomain}),\n // the useInput effect may not yet have re-registered the updated handler when\n // the first keypress arrives — causing the first space press to be silently lost.\n type InputKey = {\n leftArrow: boolean;\n rightArrow: boolean;\n upArrow: boolean;\n downArrow: boolean;\n tab: boolean;\n shift: boolean;\n };\n\n const handlerRef = useRef<((input: string, key: InputKey) => void) | null>(null);\n handlerRef.current = (input: string, key: InputKey) => {\n if (key.tab && key.shift) {\n onToggleLabels();\n return;\n }\n\n if (key.tab && !key.shift) {\n const nextSection = findNextUnlockedIndex(processedCategories, focusedRow, categories);\n if (nextSection !== focusedRow) {\n const newRowOptions = processedCategories[nextSection]?.sortedOptions || [];\n const newCol = findValidStartColumn(newRowOptions);\n setFocused(nextSection, newCol);\n }\n return;\n }\n\n if (isHotkey(input, HOTKEY_TOGGLE_LABELS)) {\n onToggleLabels();\n return;\n }\n\n if (isHotkey(input, HOTKEY_FILTER_INCOMPATIBLE) && onToggleFilterIncompatible) {\n onToggleFilterIncompatible();\n return;\n }\n\n if (input === \" \") {\n if (currentLocked) return;\n const currentOption = currentOptions[focusedCol];\n if (currentOption) {\n onToggle(currentRow.id, currentOption.id);\n }\n return;\n }\n\n const isLeft = key.leftArrow || input === \"h\";\n const isRight = key.rightArrow || input === \"l\";\n const isUp = key.upArrow || input === \"k\";\n const isDown = key.downArrow || input === \"j\";\n\n if (isLeft) {\n if (currentLocked) return;\n moveFocus(\"left\");\n } else if (isRight) {\n if (currentLocked) return;\n moveFocus(\"right\");\n } else if (isUp) {\n moveFocus(\"up\");\n } else if (isDown) {\n moveFocus(\"down\");\n }\n };\n\n // Stable handler reference — never changes, so useInput's effect registers once\n const stableHandler = useCallback((input: string, key: InputKey) => {\n handlerRef.current?.(input, key);\n }, []);\n\n useInput(stableHandler);\n}\n"],"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useCallback","useEffect","useRef","useCallback","useRef","useEffect"]}
|
|
@@ -5,9 +5,6 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
useRowScroll
|
|
7
7
|
} from "./chunk-SQ7WINEU.js";
|
|
8
|
-
import {
|
|
9
|
-
ViewTitle
|
|
10
|
-
} from "./chunk-JNQKCZA3.js";
|
|
11
8
|
import {
|
|
12
9
|
useKeyboardNavigation
|
|
13
10
|
} from "./chunk-KUV24B5M.js";
|
|
@@ -27,7 +24,7 @@ import {
|
|
|
27
24
|
addSource,
|
|
28
25
|
getSourceSummary,
|
|
29
26
|
removeSource
|
|
30
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-OIHZ2YH3.js";
|
|
31
28
|
import {
|
|
32
29
|
getErrorMessage,
|
|
33
30
|
verbose
|
|
@@ -179,10 +176,7 @@ var StepSettings = ({
|
|
|
179
176
|
}
|
|
180
177
|
});
|
|
181
178
|
if (isLoading) {
|
|
182
|
-
return /* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */ jsx(ViewTitle, { children: "Skill Sources" }),
|
|
184
|
-
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Loading sources..." })
|
|
185
|
-
] });
|
|
179
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", paddingX: 2, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Loading sources..." }) });
|
|
186
180
|
}
|
|
187
181
|
const sourceElements = summary?.sources.map((source, index) => {
|
|
188
182
|
const isFocused = index === focusedIndex && !addModal.isOpen;
|
|
@@ -206,7 +200,6 @@ var StepSettings = ({
|
|
|
206
200
|
] }, source.name);
|
|
207
201
|
});
|
|
208
202
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 2, children: [
|
|
209
|
-
/* @__PURE__ */ jsx(ViewTitle, { children: "Skill Sources" }),
|
|
210
203
|
/* @__PURE__ */ jsx(Box, { marginTop: 1 }),
|
|
211
204
|
/* @__PURE__ */ jsx(Text, { bold: true, children: "Configured marketplaces:" }),
|
|
212
205
|
/* @__PURE__ */ jsx(
|
|
@@ -270,4 +263,4 @@ var StepSettings = ({
|
|
|
270
263
|
export {
|
|
271
264
|
StepSettings
|
|
272
265
|
};
|
|
273
|
-
//# sourceMappingURL=chunk-
|
|
266
|
+
//# sourceMappingURL=chunk-YFHVP3VA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/components/wizard/step-settings.tsx","../src/cli/components/hooks/use-source-operations.ts"],"sourcesContent":["import React, { useState, useEffect, useCallback } from \"react\";\nimport { Box, Text, useInput } from \"ink\";\nimport { CLI_COLORS } from \"../../consts.js\";\nimport { ViewTitle } from \"./view-title.js\";\nimport { getSourceSummary, type SourceSummary } from \"../../lib/configuration/source-manager.js\";\nimport { DEFAULT_SOURCE } from \"../../lib/configuration/config.js\";\nimport { useKeyboardNavigation } from \"../hooks/use-keyboard-navigation.js\";\nimport { useModalState } from \"../hooks/use-modal-state.js\";\nimport { useRowScroll } from \"../hooks/use-row-scroll.js\";\nimport { useSourceOperations } from \"../hooks/use-source-operations.js\";\nimport { useTextInput } from \"../hooks/use-text-input.js\";\nimport { verbose } from \"../../utils/logger.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport {\n HOTKEY_ADD_SOURCE,\n HOTKEY_SETTINGS,\n KEY_LABEL_DEL,\n KEY_LABEL_ENTER,\n KEY_LABEL_ESC,\n isHotkey,\n} from \"./hotkeys.js\";\n\nconst DEFAULT_SOURCE_NAME = \"public\";\n\n/** Fixed lines around the source list: border top/bottom (2) */\nconst SOURCE_LIST_BORDER_LINES = 2;\n\nexport type StepSettingsProps = {\n projectDir: string;\n /** Available height in terminal lines for the scrollable source list. 0 = no constraint. */\n availableHeight?: number;\n onClose: () => void;\n};\n\nexport const StepSettings: React.FC<StepSettingsProps> = ({\n projectDir,\n availableHeight = 0,\n onClose,\n}) => {\n const [summary, setSummary] = useState<SourceSummary | null>(null);\n const addModal = useModalState();\n const {\n value: addSourceInput,\n setValue: setAddSourceInput,\n handleInput: handleTextInput,\n } = useTextInput(\"\");\n const [isLoading, setIsLoading] = useState(true);\n\n const loadSummary = useCallback(async () => {\n try {\n const result = await getSourceSummary(projectDir);\n setSummary(result);\n } catch (error) {\n verbose(`Failed to load source summary: ${getErrorMessage(error)}`);\n setSummary({\n sources: [{ name: DEFAULT_SOURCE_NAME, url: DEFAULT_SOURCE, enabled: true }],\n localSkillCount: 0,\n pluginSkillCount: 0,\n });\n }\n setIsLoading(false);\n }, [projectDir]);\n\n useEffect(() => {\n void loadSummary();\n }, [loadSummary]);\n\n const { handleAdd, handleRemove, statusMessage, clearStatus } = useSourceOperations(\n projectDir,\n loadSummary,\n );\n\n const sourceCount = summary?.sources.length ?? 0;\n\n const { focusedIndex, setFocusedIndex } = useKeyboardNavigation(\n sourceCount,\n { onEscape: onClose },\n { wrap: false, vimKeys: false, active: !addModal.isOpen },\n );\n\n // Compute scroll offset for source list\n const sourceViewportHeight =\n availableHeight > SOURCE_LIST_BORDER_LINES ? availableHeight - SOURCE_LIST_BORDER_LINES : 0;\n const { scrollEnabled, scrollTop } = useRowScroll({\n focusedIndex,\n itemCount: sourceCount,\n availableHeight: sourceViewportHeight,\n });\n\n useInput((input, key) => {\n if (statusMessage) {\n clearStatus();\n }\n\n if (addModal.isOpen) {\n if (key.escape) {\n addModal.close();\n setAddSourceInput(\"\");\n return;\n }\n\n if (key.return) {\n if (addSourceInput.trim()) {\n addModal.close();\n setAddSourceInput(\"\");\n void handleAdd(addSourceInput.trim());\n }\n return;\n }\n\n handleTextInput(input, key);\n return;\n }\n\n if (key.return) {\n // Toggle enabled/disabled is a placeholder for future enabledSources store integration\n return;\n }\n\n if (key.backspace || key.delete) {\n if (summary?.sources[focusedIndex]) {\n const source = summary.sources[focusedIndex];\n if (source.name !== DEFAULT_SOURCE_NAME) {\n void handleRemove(source.name).then((success) => {\n if (success) {\n setFocusedIndex((prev) => Math.max(0, prev - 1));\n }\n });\n }\n }\n return;\n }\n\n if (isHotkey(input, HOTKEY_ADD_SOURCE)) {\n addModal.open(true);\n setAddSourceInput(\"\");\n }\n });\n\n if (isLoading) {\n return (\n <Box flexDirection=\"column\" paddingX={2}>\n {/* <ViewTitle>Skill Sources</ViewTitle> */}\n <Text dimColor>Loading sources...</Text>\n </Box>\n );\n }\n\n const sourceElements = summary?.sources.map((source, index) => {\n const isFocused = index === focusedIndex && !addModal.isOpen;\n const isDefault = source.name === DEFAULT_SOURCE_NAME;\n const checkmark = source.enabled ? \"\\u2713\" : \" \";\n const displayName = isDefault ? \"Public\" : source.name;\n const suffix = isDefault ? \" (default)\" : \"\";\n\n return (\n <Box key={source.name} flexShrink={0}>\n <Text color={isFocused ? CLI_COLORS.PRIMARY : undefined} bold={isFocused}>\n {isFocused ? \">\" : \" \"} {checkmark} {displayName}\n </Text>\n <Text dimColor>\n {\" \"}\n {source.url}\n {suffix}\n </Text>\n </Box>\n );\n });\n\n return (\n <Box flexDirection=\"column\" paddingX={2}>\n {/* <ViewTitle>Skill Sources</ViewTitle> */}\n <Box marginTop={1} />\n\n <Text bold>Configured marketplaces:</Text>\n <Box\n flexDirection=\"column\"\n borderStyle=\"round\"\n borderColor={CLI_COLORS.NEUTRAL}\n paddingX={1}\n marginTop={1}\n >\n <Box\n flexDirection=\"column\"\n {...(scrollEnabled && { height: sourceViewportHeight, overflow: \"hidden\" as const })}\n >\n <Box\n flexDirection=\"column\"\n marginTop={scrollTop > 0 ? -scrollTop : 0}\n {...(scrollEnabled && { flexShrink: 0 })}\n >\n {sourceElements}\n </Box>\n </Box>\n </Box>\n\n <Box\n flexDirection=\"column\"\n borderStyle=\"round\"\n borderColor={addModal.isOpen ? CLI_COLORS.PRIMARY : CLI_COLORS.NEUTRAL}\n paddingX={1}\n marginTop={1}\n >\n <Text color={addModal.isOpen ? CLI_COLORS.PRIMARY : undefined}>\n + Add source: {addModal.isOpen ? addSourceInput : \"\"}\n {addModal.isOpen ? \"\\u2588\" : \"\"}\n </Text>\n </Box>\n\n {statusMessage && (\n <Box marginTop={1}>\n <Text color={statusMessage.color}>{statusMessage.text}</Text>\n </Box>\n )}\n\n <Box marginTop={1} flexDirection=\"column\">\n <Text dimColor>Local skills: {summary?.localSkillCount ?? 0} in .claude/skills/</Text>\n <Text dimColor>Plugins: {summary?.pluginSkillCount ?? 0} from installed plugins</Text>\n </Box>\n\n <Box marginTop={1}>\n <Text dimColor>\n {addModal.isOpen\n ? `${KEY_LABEL_ENTER} submit ${KEY_LABEL_ESC} cancel`\n : `${HOTKEY_ADD_SOURCE.label} add ${KEY_LABEL_DEL} remove ${KEY_LABEL_ESC} or ${HOTKEY_SETTINGS.label} to close`}\n </Text>\n </Box>\n </Box>\n );\n};\n","import { useState, useCallback } from \"react\";\nimport { CLI_COLORS } from \"../../consts.js\";\nimport { getErrorMessage } from \"../../utils/errors.js\";\nimport { addSource, removeSource } from \"../../lib/configuration/source-manager.js\";\n\ntype StatusMessage = { text: string; color: \"red\" | \"green\" } | null;\n\ntype UseSourceOperationsResult = {\n handleAdd: (url: string) => Promise<void>;\n handleRemove: (name: string) => Promise<boolean>;\n statusMessage: StatusMessage;\n clearStatus: () => void;\n};\n\nexport function useSourceOperations(\n projectDir: string,\n onReload: () => Promise<void>,\n): UseSourceOperationsResult {\n const [statusMessage, setStatusMessage] = useState<StatusMessage>(null);\n\n const handleAdd = useCallback(\n async (url: string) => {\n try {\n const result = await addSource(projectDir, url);\n setStatusMessage({\n text: `Added \"${result.name}\" (${result.skillCount} skills)`,\n color: CLI_COLORS.SUCCESS,\n });\n await onReload();\n } catch (error) {\n const message = getErrorMessage(error);\n setStatusMessage({ text: `Failed to add source: ${message}`, color: CLI_COLORS.ERROR });\n }\n },\n [projectDir, onReload],\n );\n\n const handleRemove = useCallback(\n async (name: string): Promise<boolean> => {\n try {\n await removeSource(projectDir, name);\n setStatusMessage({ text: `Removed \"${name}\"`, color: CLI_COLORS.SUCCESS });\n await onReload();\n return true;\n } catch (error) {\n const message = getErrorMessage(error);\n setStatusMessage({ text: `Failed to remove: ${message}`, color: CLI_COLORS.ERROR });\n return false;\n }\n },\n [projectDir, onReload],\n );\n\n const clearStatus = useCallback(() => {\n setStatusMessage(null);\n }, []);\n\n return { handleAdd, handleRemove, statusMessage, clearStatus };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAgB,YAAAA,WAAU,WAAW,eAAAC,oBAAmB;AACxD,SAAS,KAAK,MAAM,gBAAgB;;;ACDpC;AAAA,SAAS,UAAU,mBAAmB;AAc/B,SAAS,oBACd,YACA,UAC2B;AAC3B,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAEtE,QAAM,YAAY;AAAA,IAChB,OAAO,QAAgB;AACrB,UAAI;AACF,cAAM,SAAS,MAAM,UAAU,YAAY,GAAG;AAC9C,yBAAiB;AAAA,UACf,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;AAAA,UAClD,OAAO,WAAW;AAAA,QACpB,CAAC;AACD,cAAM,SAAS;AAAA,MACjB,SAAS,OAAO;AACd,cAAM,UAAU,gBAAgB,KAAK;AACrC,yBAAiB,EAAE,MAAM,yBAAyB,OAAO,IAAI,OAAO,WAAW,MAAM,CAAC;AAAA,MACxF;AAAA,IACF;AAAA,IACA,CAAC,YAAY,QAAQ;AAAA,EACvB;AAEA,QAAM,eAAe;AAAA,IACnB,OAAO,SAAmC;AACxC,UAAI;AACF,cAAM,aAAa,YAAY,IAAI;AACnC,yBAAiB,EAAE,MAAM,YAAY,IAAI,KAAK,OAAO,WAAW,QAAQ,CAAC;AACzE,cAAM,SAAS;AACf,eAAO;AAAA,MACT,SAAS,OAAO;AACd,cAAM,UAAU,gBAAgB,KAAK;AACrC,yBAAiB,EAAE,MAAM,qBAAqB,OAAO,IAAI,OAAO,WAAW,MAAM,CAAC;AAClF,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,YAAY,QAAQ;AAAA,EACvB;AA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AU,QAAW;AAAA;AAAA,UAC9C,SAAS,SAAS,iBAAiB;AAAA,UACjD,SAAS,SAAS,WAAW;AAAA,WAChC;AAAA;AAAA,IACF;AAAA,IAEC,iBACC,oBAAC,OAAI,WAAW,GACd,8BAAC,QAAK,OAAO,cAAc,OAAQ,wBAAc,MAAK,GACxD;AAAA,IAGF,qBAAC,OAAI,WAAW,GAAG,eAAc,UAC/B;AAAA,2BAAC,QAAK,UAAQ,MAAC;AAAA;AAAA,QAAe,SAAS,mBAAmB;AAAA,QAAE;AAAA,SAAmB;AAAA,MAC/E,qBAAC,QAAK,UAAQ,MAAC;AAAA;AAAA,QAAU,SAAS,oBAAoB;AAAA,QAAE;AAAA,SAAuB;AAAA,OACjF;AAAA,IAEA,oBAAC,OAAI,WAAW,GACd,8BAAC,QAAK,UAAQ,MACX,mBAAS,SACN,GAAG,eAAe,YAAY,aAAa,YAC3C,GAAG,kBAAkB,KAAK,SAAS,aAAa,YAAY,aAAa,OAAO,gBAAgB,KAAK,aAC3G,GACF;AAAA,KACF;AAEJ;","names":["useState","useCallback","useState","useCallback"]}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
compileAllAgentPlugins,
|
|
4
4
|
printAgentCompilationSummary
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-SJNUTUSJ.js";
|
|
6
6
|
import {
|
|
7
7
|
compileAllSkillPlugins,
|
|
8
8
|
compileSkillPlugin,
|
|
9
9
|
printCompilationSummary
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-OIHZ2YH3.js";
|
|
11
11
|
import "../../chunk-IFCASC6R.js";
|
|
12
12
|
import "../../chunk-FSK4TQX7.js";
|
|
13
13
|
import {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
getAgentDefinitions
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-SJNUTUSJ.js";
|
|
5
5
|
import {
|
|
6
6
|
compileStackPlugin,
|
|
7
7
|
loadStacks,
|
|
8
8
|
printStackCompilationSummary
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-OIHZ2YH3.js";
|
|
10
10
|
import "../../chunk-IFCASC6R.js";
|
|
11
11
|
import "../../chunk-FSK4TQX7.js";
|
|
12
12
|
import {
|
package/dist/commands/compile.js
CHANGED
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
import {
|
|
3
3
|
getAgentDefinitions,
|
|
4
4
|
recompileAgents
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-SJNUTUSJ.js";
|
|
6
6
|
import {
|
|
7
7
|
ERROR_MESSAGES,
|
|
8
8
|
INFO_MESSAGES,
|
|
9
9
|
STATUS_MESSAGES
|
|
10
10
|
} from "../chunk-M76LNKMY.js";
|
|
11
11
|
import {
|
|
12
|
+
buildAgentScopeMap,
|
|
12
13
|
detectGlobalInstallation,
|
|
13
14
|
detectProjectInstallation,
|
|
14
15
|
discoverAllPluginSkills,
|
|
16
|
+
loadProjectConfigFromDir,
|
|
15
17
|
resolveSource
|
|
16
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-OIHZ2YH3.js";
|
|
17
19
|
import {
|
|
18
20
|
parseFrontmatter
|
|
19
21
|
} from "../chunk-IFCASC6R.js";
|
|
@@ -139,13 +141,15 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
139
141
|
await this.resolveSourceForCompile(flags);
|
|
140
142
|
const agentDefs = await this.loadAgentDefsForCompile(flags);
|
|
141
143
|
let totalPassesWithSkills = 0;
|
|
144
|
+
const hasBothScopes = !!globalInstallation && !!projectInstallation;
|
|
142
145
|
if (globalInstallation) {
|
|
143
146
|
const hadSkills = await this.runCompilePass({
|
|
144
147
|
label: "Global",
|
|
145
148
|
projectDir: homeDir,
|
|
146
149
|
installation: globalInstallation,
|
|
147
150
|
agentDefs,
|
|
148
|
-
flags
|
|
151
|
+
flags,
|
|
152
|
+
scopeFilter: hasBothScopes ? "global" : void 0
|
|
149
153
|
});
|
|
150
154
|
if (hadSkills) totalPassesWithSkills++;
|
|
151
155
|
}
|
|
@@ -155,7 +159,8 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
155
159
|
projectDir: cwd,
|
|
156
160
|
installation: projectInstallation,
|
|
157
161
|
agentDefs,
|
|
158
|
-
flags
|
|
162
|
+
flags,
|
|
163
|
+
scopeFilter: hasBothScopes ? "project" : void 0
|
|
159
164
|
});
|
|
160
165
|
if (hadSkills) totalPassesWithSkills++;
|
|
161
166
|
}
|
|
@@ -168,38 +173,44 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
168
173
|
}
|
|
169
174
|
async discoverAllSkills(projectDir = process.cwd()) {
|
|
170
175
|
this.log(STATUS_MESSAGES.DISCOVERING_SKILLS);
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
const isGlobalProject = projectDir === os.homedir();
|
|
177
|
+
const globalPluginSkills = isGlobalProject ? {} : await discoverAllPluginSkills(os.homedir());
|
|
178
|
+
const globalPluginSkillCount = typedKeys(globalPluginSkills).length;
|
|
179
|
+
if (globalPluginSkillCount > 0) {
|
|
180
|
+
verbose(` Found ${globalPluginSkillCount} skills from global plugins`);
|
|
181
|
+
}
|
|
175
182
|
const globalLocalSkillsDir = path.join(GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH);
|
|
176
183
|
const globalLocalSkills = isGlobalProject ? {} : await loadSkillsFromDir(globalLocalSkillsDir, LOCAL_SKILLS_PATH);
|
|
177
184
|
const globalLocalSkillCount = typedKeys(globalLocalSkills).length;
|
|
178
185
|
if (globalLocalSkillCount > 0) {
|
|
179
186
|
verbose(` Found ${globalLocalSkillCount} global local skills from ~/.claude/skills/`);
|
|
180
187
|
}
|
|
188
|
+
const pluginSkills = await discoverAllPluginSkills(projectDir);
|
|
189
|
+
const pluginSkillCount = typedKeys(pluginSkills).length;
|
|
190
|
+
verbose(` Found ${pluginSkillCount} skills from installed plugins`);
|
|
181
191
|
const localSkills = await discoverLocalProjectSkills(projectDir);
|
|
182
192
|
const localSkillCount = typedKeys(localSkills).length;
|
|
183
193
|
verbose(` Found ${localSkillCount} local skills from .claude/skills/`);
|
|
184
|
-
const allSkills = mergeSkills(
|
|
194
|
+
const allSkills = mergeSkills(globalPluginSkills, globalLocalSkills, pluginSkills, localSkills);
|
|
185
195
|
const totalSkillCount = typedKeys(allSkills).length;
|
|
186
196
|
if (totalSkillCount === 0) {
|
|
187
197
|
return { allSkills, totalSkillCount };
|
|
188
198
|
}
|
|
189
|
-
|
|
190
|
-
|
|
199
|
+
const totalPluginSkillCount = globalPluginSkillCount + pluginSkillCount;
|
|
200
|
+
if (totalPluginSkillCount > 0 && totalSkillCount > totalPluginSkillCount) {
|
|
201
|
+
const localCount = totalSkillCount - totalPluginSkillCount;
|
|
191
202
|
this.log(
|
|
192
|
-
`Discovered ${totalSkillCount} skills (${
|
|
203
|
+
`Discovered ${totalSkillCount} skills (${totalPluginSkillCount} from plugins, ${localCount} local)`
|
|
193
204
|
);
|
|
194
|
-
} else if (
|
|
195
|
-
this.log(`Discovered ${
|
|
205
|
+
} else if (totalPluginSkillCount > 0) {
|
|
206
|
+
this.log(`Discovered ${totalPluginSkillCount} skills from plugins`);
|
|
196
207
|
} else {
|
|
197
208
|
this.log(`Discovered ${totalSkillCount} local skills`);
|
|
198
209
|
}
|
|
199
210
|
return { allSkills, totalSkillCount };
|
|
200
211
|
}
|
|
201
212
|
async runCompilePass(params) {
|
|
202
|
-
const { label, projectDir, installation, agentDefs, flags } = params;
|
|
213
|
+
const { label, projectDir, installation, agentDefs, flags, scopeFilter } = params;
|
|
203
214
|
this.log("");
|
|
204
215
|
this.log(`Compiling ${label.toLowerCase()} agents...`);
|
|
205
216
|
this.log("");
|
|
@@ -210,6 +221,9 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
210
221
|
this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);
|
|
211
222
|
return false;
|
|
212
223
|
}
|
|
224
|
+
const loadedConfig = await loadProjectConfigFromDir(projectDir);
|
|
225
|
+
const agentScopeMap = loadedConfig?.config ? buildAgentScopeMap(loadedConfig.config) : void 0;
|
|
226
|
+
const filteredAgents = scopeFilter && loadedConfig?.config?.agents ? loadedConfig.config.agents.filter((a) => a.scope === scopeFilter).map((a) => a.name) : void 0;
|
|
213
227
|
this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);
|
|
214
228
|
try {
|
|
215
229
|
const recompileResult = await recompileAgents({
|
|
@@ -217,7 +231,9 @@ var Compile = class _Compile extends BaseCommand {
|
|
|
217
231
|
sourcePath: agentDefs.sourcePath,
|
|
218
232
|
skills: allSkills,
|
|
219
233
|
projectDir,
|
|
220
|
-
outputDir: installation.agentsDir
|
|
234
|
+
outputDir: installation.agentsDir,
|
|
235
|
+
agentScopeMap,
|
|
236
|
+
agents: filteredAgents
|
|
221
237
|
});
|
|
222
238
|
if (recompileResult.failed.length > 0) {
|
|
223
239
|
this.log(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/compile.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport os from \"os\";\nimport path from \"path\";\nimport { BaseCommand } from \"../base-command\";\nimport { setVerbose, verbose, warn } from \"../utils/logger\";\nimport { discoverAllPluginSkills } from \"../lib/plugins\";\nimport { getAgentDefinitions } from \"../lib/agents\";\nimport { resolveSource } from \"../lib/configuration\";\nimport { directoryExists, glob, readFile, fileExists } from \"../utils/fs\";\nimport { recompileAgents } from \"../lib/agents\";\nimport { parseFrontmatter } from \"../lib/loading\";\nimport { CLI_BIN_NAME, GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../consts\";\nimport { EXIT_CODES } from \"../lib/exit-codes\";\nimport { ERROR_MESSAGES, STATUS_MESSAGES, INFO_MESSAGES } from \"../utils/messages\";\nimport {\n detectGlobalInstallation,\n detectProjectInstallation,\n type Installation,\n} from \"../lib/installation\";\nimport type { AgentSourcePaths, SkillDefinition, SkillDefinitionMap, SkillId } from \"../types\";\nimport { typedEntries, typedKeys } from \"../utils/typed-object\";\n\nasync function loadSkillsFromDir(skillsDir: string, pathPrefix = \"\"): 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\nasync 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/** Later sources take precedence over earlier ones */\nfunction 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\ntype CompileFlags = {\n source?: string;\n \"agent-source\"?: string;\n verbose: boolean;\n};\n\ntype DiscoveredSkills = {\n allSkills: SkillDefinitionMap;\n totalSkillCount: number;\n};\n\nexport default class Compile extends BaseCommand {\n static summary = \"Compile agents using local skills and agent definitions\";\n\n static description =\n \"Compile agents with resolved skill references. Compiles to the Claude plugin directory.\";\n\n static examples = [\n \"<%= config.bin %> <%= command.id %>\",\n \"<%= config.bin %> <%= command.id %> --verbose\",\n ];\n\n static flags = {\n ...BaseCommand.baseFlags,\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n \"agent-source\": Flags.string({\n description: \"Remote agent partials source (default: local CLI)\",\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Compile);\n\n setVerbose(flags.verbose);\n\n const cwd = process.cwd();\n const homeDir = os.homedir();\n\n const globalInstallation = await detectGlobalInstallation();\n // Skip project detection when cwd is home directory to avoid double-compile\n const projectInstallation = cwd === homeDir ? null : await detectProjectInstallation(cwd);\n\n if (!globalInstallation && !projectInstallation) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n await this.resolveSourceForCompile(flags);\n const agentDefs = await this.loadAgentDefsForCompile(flags);\n\n let totalPassesWithSkills = 0;\n\n if (globalInstallation) {\n const hadSkills = await this.runCompilePass({\n label: \"Global\",\n projectDir: homeDir,\n installation: globalInstallation,\n agentDefs,\n flags,\n });\n if (hadSkills) totalPassesWithSkills++;\n }\n\n if (projectInstallation) {\n const hadSkills = await this.runCompilePass({\n label: \"Project\",\n projectDir: cwd,\n installation: projectInstallation,\n agentDefs,\n flags,\n });\n if (hadSkills) totalPassesWithSkills++;\n }\n\n if (totalPassesWithSkills === 0) {\n this.error(\n `No skills found. Add skills with '${CLI_BIN_NAME} add <skill>' or create in .claude/skills/.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n }\n\n private async discoverAllSkills(projectDir: string = process.cwd()): Promise<DiscoveredSkills> {\n this.log(STATUS_MESSAGES.DISCOVERING_SKILLS);\n\n const pluginSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillCount = typedKeys<SkillId>(pluginSkills).length;\n verbose(` Found ${pluginSkillCount} skills from installed plugins`);\n\n // Load global local skills (skip if projectDir is already the home directory to avoid double-loading)\n const isGlobalProject = projectDir === GLOBAL_INSTALL_ROOT;\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 const localSkills = await discoverLocalProjectSkills(projectDir);\n const localSkillCount = typedKeys<SkillId>(localSkills).length;\n verbose(` Found ${localSkillCount} local skills from .claude/skills/`);\n\n // Global skills loaded first, project skills second — project wins on conflict (later sources override)\n const allSkills = mergeSkills(pluginSkills, globalLocalSkills, localSkills);\n const totalSkillCount = typedKeys<SkillId>(allSkills).length;\n\n if (totalSkillCount === 0) {\n return { allSkills, totalSkillCount };\n }\n\n if (pluginSkillCount > 0 && totalSkillCount > pluginSkillCount) {\n const localCount = totalSkillCount - pluginSkillCount;\n this.log(\n `Discovered ${totalSkillCount} skills (${pluginSkillCount} from plugins, ${localCount} local)`,\n );\n } else if (pluginSkillCount > 0) {\n this.log(`Discovered ${pluginSkillCount} skills from plugins`);\n } else {\n this.log(`Discovered ${totalSkillCount} local skills`);\n }\n\n return { allSkills, totalSkillCount };\n }\n\n private async runCompilePass(params: {\n label: string;\n projectDir: string;\n installation: Installation;\n agentDefs: AgentSourcePaths;\n flags: CompileFlags;\n }): Promise<boolean> {\n const { label, projectDir, installation, agentDefs, flags } = params;\n\n this.log(\"\");\n this.log(`Compiling ${label.toLowerCase()} agents...`);\n this.log(\"\");\n\n verbose(` Project: ${projectDir}`);\n verbose(` Agents: ${installation.agentsDir}`);\n\n const { allSkills, totalSkillCount } = await this.discoverAllSkills(projectDir);\n\n if (totalSkillCount === 0) {\n this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);\n return false;\n }\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const recompileResult = await recompileAgents({\n pluginDir: projectDir,\n sourcePath: agentDefs.sourcePath,\n skills: allSkills,\n projectDir,\n outputDir: installation.agentsDir,\n });\n\n if (recompileResult.failed.length > 0) {\n this.log(\n `Recompiled ${recompileResult.compiled.length} ${label.toLowerCase()} agents (${recompileResult.failed.length} failed)`,\n );\n for (const warning of recompileResult.warnings) {\n this.warn(warning);\n }\n } else if (recompileResult.compiled.length > 0) {\n this.log(`Recompiled ${recompileResult.compiled.length} ${label.toLowerCase()} agents`);\n } else {\n this.log(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE);\n }\n\n if (recompileResult.compiled.length > 0) {\n verbose(` Compiled: ${recompileResult.compiled.join(\", \")}`);\n }\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_COMPILE_AGENTS);\n this.handleError(error);\n }\n\n this.log(\"\");\n this.logSuccess(`${label} compile complete!`);\n this.log(\"\");\n\n return true;\n }\n\n private async resolveSourceForCompile(flags: CompileFlags): Promise<void> {\n this.log(STATUS_MESSAGES.RESOLVING_SOURCE);\n try {\n const sourceConfig = await resolveSource(flags.source);\n this.log(`Source: ${sourceConfig.sourceOrigin}`);\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_RESOLVE_SOURCE);\n this.handleError(error);\n }\n }\n\n private async loadAgentDefsForCompile(flags: CompileFlags): Promise<AgentSourcePaths> {\n const projectDir = process.cwd();\n this.log(\n flags[\"agent-source\"]\n ? STATUS_MESSAGES.FETCHING_AGENT_PARTIALS\n : STATUS_MESSAGES.LOADING_AGENT_PARTIALS,\n );\n\n try {\n const agentDefs = await getAgentDefinitions(flags[\"agent-source\"], {\n projectDir,\n });\n this.log(flags[\"agent-source\"] ? \"Agent partials fetched\" : \"Agent partials loaded\");\n verbose(` Agents: ${agentDefs.agentsDir}`);\n verbose(` Templates: ${agentDefs.templatesDir}`);\n return agentDefs;\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_LOAD_AGENT_PARTIALS);\n return this.handleError(error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,OAAO,UAAU;AAoBjB,eAAe,kBAAkB,WAAmB,aAAa,IAAiC;AAChG,QAAM,SAA6B,CAAC;AAEpC,MAAI,CAAE,MAAM,gBAAgB,SAAS,GAAI;AACvC,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,MAAM,KAAK,eAAe,SAAS;AAEtD,aAAW,aAAa,YAAY;AAClC,UAAM,YAAY,KAAK,KAAK,WAAW,SAAS;AAChD,UAAM,WAAW,KAAK,QAAQ,SAAS;AACvC,UAAM,eAAe,KAAK,SAAS,WAAW,QAAQ;AACtD,UAAM,eAAe,KAAK,SAAS,QAAQ;AAE3C,UAAM,eAAe,KAAK,KAAK,UAAU,eAAe,aAAa;AACrE,QAAI,CAAE,MAAM,WAAW,YAAY,GAAI;AACrC,YAAM,cAAc,aAAa,GAAG,UAAU,IAAI,YAAY,MAAM,GAAG,YAAY;AACnF;AAAA,QACE,UAAU,YAAY,SAAS,WAAW,gBAAgB,eAAe,aAAa,wBAAmB,eAAe,aAAa;AAAA,MACvI;AACA;AAAA,IACF;AAEA,QAAI;AACF,YAAM,UAAU,MAAM,SAAS,SAAS;AACxC,YAAM,cAAc,iBAAiB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BAChB,gBAAgB;AAAA,IACtB;AAEA,QAAI;AACF,YAAM,YAAY,MAAM,oBAAoB,MAAM,cAAc,GAAG;AAAA,QACjE;AAAA,MACF,CAAC;AACD,WAAK,IAAI,MAAM,cAAc,IAAI,2BAA2B,uBAAuB;AACnF,cAAQ,aAAa,UAAU,SAAS,EAAE;AAC1C,cAAQ,gBAAgB,UAAU,YAAY,EAAE;AAChD,aAAO;AAAA,IACT,SAAS,OAAO;AACd,WAAK,IAAI,eAAe,0BAA0B;AAClD,aAAO,KAAK,YAAY,KAAK;AAAA,IAC/B;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/compile.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport os from \"os\";\nimport path from \"path\";\nimport { BaseCommand } from \"../base-command\";\nimport { setVerbose, verbose, warn } from \"../utils/logger\";\nimport { discoverAllPluginSkills } from \"../lib/plugins\";\nimport { getAgentDefinitions } from \"../lib/agents\";\nimport { resolveSource, loadProjectConfigFromDir } from \"../lib/configuration\";\nimport { directoryExists, glob, readFile, fileExists } from \"../utils/fs\";\nimport { recompileAgents } from \"../lib/agents\";\nimport { parseFrontmatter } from \"../lib/loading\";\nimport { CLI_BIN_NAME, GLOBAL_INSTALL_ROOT, LOCAL_SKILLS_PATH, STANDARD_FILES } from \"../consts\";\nimport { EXIT_CODES } from \"../lib/exit-codes\";\nimport { ERROR_MESSAGES, STATUS_MESSAGES, INFO_MESSAGES } from \"../utils/messages\";\nimport {\n buildAgentScopeMap,\n detectGlobalInstallation,\n detectProjectInstallation,\n type Installation,\n} from \"../lib/installation\";\nimport type { AgentSourcePaths, SkillDefinition, SkillDefinitionMap, SkillId } from \"../types\";\nimport { typedEntries, typedKeys } from \"../utils/typed-object\";\n\nasync function loadSkillsFromDir(skillsDir: string, pathPrefix = \"\"): 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\nasync 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/** Later sources take precedence over earlier ones */\nfunction 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\ntype CompileFlags = {\n source?: string;\n \"agent-source\"?: string;\n verbose: boolean;\n};\n\ntype DiscoveredSkills = {\n allSkills: SkillDefinitionMap;\n totalSkillCount: number;\n};\n\nexport default class Compile extends BaseCommand {\n static summary = \"Compile agents using local skills and agent definitions\";\n\n static description =\n \"Compile agents with resolved skill references. Compiles to the Claude plugin directory.\";\n\n static examples = [\n \"<%= config.bin %> <%= command.id %>\",\n \"<%= config.bin %> <%= command.id %> --verbose\",\n ];\n\n static flags = {\n ...BaseCommand.baseFlags,\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Enable verbose logging\",\n default: false,\n }),\n \"agent-source\": Flags.string({\n description: \"Remote agent partials source (default: local CLI)\",\n }),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(Compile);\n\n setVerbose(flags.verbose);\n\n const cwd = process.cwd();\n const homeDir = os.homedir();\n\n const globalInstallation = await detectGlobalInstallation();\n // Skip project detection when cwd is home directory to avoid double-compile\n const projectInstallation = cwd === homeDir ? null : await detectProjectInstallation(cwd);\n\n if (!globalInstallation && !projectInstallation) {\n this.error(ERROR_MESSAGES.NO_INSTALLATION, {\n exit: EXIT_CODES.ERROR,\n });\n }\n\n await this.resolveSourceForCompile(flags);\n const agentDefs = await this.loadAgentDefsForCompile(flags);\n\n let totalPassesWithSkills = 0;\n\n // When both installations exist, filter each pass to its own scope to prevent\n // the project pass from overwriting global agents with zero-skill versions\n // (the project config's stack only has project agent entries).\n const hasBothScopes = !!globalInstallation && !!projectInstallation;\n\n if (globalInstallation) {\n const hadSkills = await this.runCompilePass({\n label: \"Global\",\n projectDir: homeDir,\n installation: globalInstallation,\n agentDefs,\n flags,\n scopeFilter: hasBothScopes ? \"global\" : undefined,\n });\n if (hadSkills) totalPassesWithSkills++;\n }\n\n if (projectInstallation) {\n const hadSkills = await this.runCompilePass({\n label: \"Project\",\n projectDir: cwd,\n installation: projectInstallation,\n agentDefs,\n flags,\n scopeFilter: hasBothScopes ? \"project\" : undefined,\n });\n if (hadSkills) totalPassesWithSkills++;\n }\n\n if (totalPassesWithSkills === 0) {\n this.error(\n `No skills found. Add skills with '${CLI_BIN_NAME} add <skill>' or create in .claude/skills/.`,\n { exit: EXIT_CODES.ERROR },\n );\n }\n }\n\n private async discoverAllSkills(projectDir: string = process.cwd()): Promise<DiscoveredSkills> {\n this.log(STATUS_MESSAGES.DISCOVERING_SKILLS);\n\n // Load global plugins (skip if projectDir is already the home directory to avoid double-loading)\n const isGlobalProject = projectDir === os.homedir();\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 // Load global local skills (skip if projectDir is already the home directory to avoid double-loading)\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 const pluginSkills = await discoverAllPluginSkills(projectDir);\n const pluginSkillCount = typedKeys<SkillId>(pluginSkills).length;\n verbose(` Found ${pluginSkillCount} skills from installed plugins`);\n\n const localSkills = await discoverLocalProjectSkills(projectDir);\n const localSkillCount = typedKeys<SkillId>(localSkills).length;\n verbose(` Found ${localSkillCount} local skills from .claude/skills/`);\n\n // Global skills loaded first, project skills second — project wins on conflict (later sources override)\n const allSkills = mergeSkills(globalPluginSkills, globalLocalSkills, pluginSkills, localSkills);\n const totalSkillCount = typedKeys<SkillId>(allSkills).length;\n\n if (totalSkillCount === 0) {\n return { allSkills, totalSkillCount };\n }\n\n const totalPluginSkillCount = globalPluginSkillCount + pluginSkillCount;\n if (totalPluginSkillCount > 0 && totalSkillCount > totalPluginSkillCount) {\n const localCount = totalSkillCount - totalPluginSkillCount;\n this.log(\n `Discovered ${totalSkillCount} skills (${totalPluginSkillCount} from plugins, ${localCount} local)`,\n );\n } else if (totalPluginSkillCount > 0) {\n this.log(`Discovered ${totalPluginSkillCount} skills from plugins`);\n } else {\n this.log(`Discovered ${totalSkillCount} local skills`);\n }\n\n return { allSkills, totalSkillCount };\n }\n\n private async runCompilePass(params: {\n label: string;\n projectDir: string;\n installation: Installation;\n agentDefs: AgentSourcePaths;\n flags: CompileFlags;\n /** When true, only compile agents matching this scope (filters out agents handled by another pass) */\n scopeFilter?: \"project\" | \"global\";\n }): Promise<boolean> {\n const { label, projectDir, installation, agentDefs, flags, scopeFilter } = params;\n\n this.log(\"\");\n this.log(`Compiling ${label.toLowerCase()} agents...`);\n this.log(\"\");\n\n verbose(` Project: ${projectDir}`);\n verbose(` Agents: ${installation.agentsDir}`);\n\n const { allSkills, totalSkillCount } = await this.discoverAllSkills(projectDir);\n\n if (totalSkillCount === 0) {\n this.log(`No skills found for ${label.toLowerCase()} pass, skipping`);\n return false;\n }\n\n // Load config to build scope map so agents are routed to the correct directory\n const loadedConfig = await loadProjectConfigFromDir(projectDir);\n const agentScopeMap = loadedConfig?.config\n ? buildAgentScopeMap(loadedConfig.config)\n : undefined;\n\n // When a scope filter is active, only compile agents matching that scope.\n // This prevents the project pass from overwriting global agents (which were already compiled\n // in the global pass) with zero-skill versions (the project stack only has project entries).\n const filteredAgents =\n scopeFilter && loadedConfig?.config?.agents\n ? loadedConfig.config.agents.filter((a) => a.scope === scopeFilter).map((a) => a.name)\n : undefined;\n\n this.log(STATUS_MESSAGES.RECOMPILING_AGENTS);\n try {\n const recompileResult = await recompileAgents({\n pluginDir: projectDir,\n sourcePath: agentDefs.sourcePath,\n skills: allSkills,\n projectDir,\n outputDir: installation.agentsDir,\n agentScopeMap,\n agents: filteredAgents,\n });\n\n if (recompileResult.failed.length > 0) {\n this.log(\n `Recompiled ${recompileResult.compiled.length} ${label.toLowerCase()} agents (${recompileResult.failed.length} failed)`,\n );\n for (const warning of recompileResult.warnings) {\n this.warn(warning);\n }\n } else if (recompileResult.compiled.length > 0) {\n this.log(`Recompiled ${recompileResult.compiled.length} ${label.toLowerCase()} agents`);\n } else {\n this.log(INFO_MESSAGES.NO_AGENTS_TO_RECOMPILE);\n }\n\n if (recompileResult.compiled.length > 0) {\n verbose(` Compiled: ${recompileResult.compiled.join(\", \")}`);\n }\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_COMPILE_AGENTS);\n this.handleError(error);\n }\n\n this.log(\"\");\n this.logSuccess(`${label} compile complete!`);\n this.log(\"\");\n\n return true;\n }\n\n private async resolveSourceForCompile(flags: CompileFlags): Promise<void> {\n this.log(STATUS_MESSAGES.RESOLVING_SOURCE);\n try {\n const sourceConfig = await resolveSource(flags.source);\n this.log(`Source: ${sourceConfig.sourceOrigin}`);\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_RESOLVE_SOURCE);\n this.handleError(error);\n }\n }\n\n private async loadAgentDefsForCompile(flags: CompileFlags): Promise<AgentSourcePaths> {\n const projectDir = process.cwd();\n this.log(\n flags[\"agent-source\"]\n ? STATUS_MESSAGES.FETCHING_AGENT_PARTIALS\n : STATUS_MESSAGES.LOADING_AGENT_PARTIALS,\n );\n\n try {\n const agentDefs = await getAgentDefinitions(flags[\"agent-source\"], {\n projectDir,\n });\n this.log(flags[\"agent-source\"] ? \"Agent partials fetched\" : \"Agent partials loaded\");\n verbose(` Agents: ${agentDefs.agentsDir}`);\n verbose(` Templates: ${agentDefs.templatesDir}`);\n return agentDefs;\n } catch (error) {\n this.log(ERROR_MESSAGES.FAILED_LOAD_AGENT_PARTIALS);\n return this.handleError(error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,aAAa;AACtB,OAAO,QAAQ;AACf,OAAO,UAAU;AAqBjB,eAAe,kBAAkB,WAAmB,aAAa,IAAiC;AAChG,QAAM,SAA6B,CAAC;AAEpC,MAAI,CAAE,MAAM,gBAAgB,SAAS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,0BAChB,gBAAgB;AAAA,IACtB;AAEA,QAAI;AACF,YAAM,YAAY,MAAM,oBAAoB,MAAM,cAAc,GAAG;AAAA,QACjE;AAAA,MACF,CAAC;AACD,WAAK,IAAI,MAAM,cAAc,IAAI,2BAA2B,uBAAuB;AACnF,cAAQ,aAAa,UAAU,SAAS,EAAE;AAC1C,cAAQ,gBAAgB,UAAU,YAAY,EAAE;AAChD,aAAO;AAAA,IACT,SAAS,OAAO;AACd,WAAK,IAAI,eAAe,0BAA0B;AAClD,aAAO,KAAK,YAAY,KAAK;AAAA,IAC/B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigShow
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-7HGMFJ4Y.js";
|
|
5
|
+
import "../../chunk-OIHZ2YH3.js";
|
|
6
6
|
import "../../chunk-IFCASC6R.js";
|
|
7
7
|
import "../../chunk-FSK4TQX7.js";
|
|
8
8
|
import "../../chunk-7LBYURQR.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigShow
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-7HGMFJ4Y.js";
|
|
5
|
+
import "../../chunk-OIHZ2YH3.js";
|
|
6
6
|
import "../../chunk-IFCASC6R.js";
|
|
7
7
|
import "../../chunk-FSK4TQX7.js";
|
|
8
8
|
import "../../chunk-7LBYURQR.js";
|
package/dist/commands/diff.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
loadSkillsMatrixFromSource,
|
|
4
4
|
readForkedFromMetadata
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-OIHZ2YH3.js";
|
|
6
6
|
import "../chunk-IFCASC6R.js";
|
|
7
7
|
import "../chunk-FSK4TQX7.js";
|
|
8
8
|
import {
|
|
@@ -532,6 +532,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
532
532
|
var source_default = chalk;
|
|
533
533
|
|
|
534
534
|
// src/cli/commands/diff.ts
|
|
535
|
+
import os2 from "os";
|
|
535
536
|
import path from "path";
|
|
536
537
|
import { createTwoFilesPatch } from "diff";
|
|
537
538
|
function colorDiff(diffText) {
|
|
@@ -647,8 +648,12 @@ var Diff = class _Diff extends BaseCommand {
|
|
|
647
648
|
async run() {
|
|
648
649
|
const { args, flags } = await this.parse(_Diff);
|
|
649
650
|
const projectDir = process.cwd();
|
|
650
|
-
const
|
|
651
|
-
|
|
651
|
+
const homeDir = os2.homedir();
|
|
652
|
+
const projectLocalPath = path.join(projectDir, LOCAL_SKILLS_PATH);
|
|
653
|
+
const globalLocalPath = path.join(homeDir, LOCAL_SKILLS_PATH);
|
|
654
|
+
const hasProject = await fileExists(projectLocalPath);
|
|
655
|
+
const hasGlobal = projectDir !== homeDir && await fileExists(globalLocalPath);
|
|
656
|
+
if (!hasProject && !hasGlobal) {
|
|
652
657
|
if (!flags.quiet) {
|
|
653
658
|
this.warn(
|
|
654
659
|
`No local skills found. Run '${CLI_BIN_NAME} init' or '${CLI_BIN_NAME} edit' first.`
|
|
@@ -674,24 +679,39 @@ var Diff = class _Diff extends BaseCommand {
|
|
|
674
679
|
sourceSkills[skillId] = { path: skill.path };
|
|
675
680
|
}
|
|
676
681
|
}
|
|
677
|
-
|
|
682
|
+
const scopedDirs = [];
|
|
683
|
+
if (hasProject) {
|
|
684
|
+
for (const dirName of await listDirectories(projectLocalPath)) {
|
|
685
|
+
scopedDirs.push({ dirName, localSkillsPath: projectLocalPath });
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (hasGlobal) {
|
|
689
|
+
const projectDirNames = new Set(scopedDirs.map((d) => d.dirName));
|
|
690
|
+
for (const dirName of await listDirectories(globalLocalPath)) {
|
|
691
|
+
if (!projectDirNames.has(dirName)) {
|
|
692
|
+
scopedDirs.push({ dirName, localSkillsPath: globalLocalPath });
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
678
696
|
if (args.skill) {
|
|
679
|
-
|
|
680
|
-
if (
|
|
697
|
+
const filtered = scopedDirs.filter((d) => d.dirName === args.skill);
|
|
698
|
+
if (filtered.length === 0) {
|
|
681
699
|
if (!flags.quiet) {
|
|
682
700
|
this.error(`Skill '${args.skill}' not found in local skills`, {
|
|
683
701
|
exit: EXIT_CODES.ERROR
|
|
684
702
|
});
|
|
685
703
|
}
|
|
686
704
|
}
|
|
705
|
+
scopedDirs.length = 0;
|
|
706
|
+
scopedDirs.push(...filtered);
|
|
687
707
|
}
|
|
688
708
|
const results = [];
|
|
689
709
|
const skillsWithoutForkedFrom = [];
|
|
690
|
-
for (const
|
|
691
|
-
const result = await diffSkill(localSkillsPath,
|
|
710
|
+
for (const { dirName, localSkillsPath } of scopedDirs) {
|
|
711
|
+
const result = await diffSkill(localSkillsPath, dirName, sourcePath, sourceSkills);
|
|
692
712
|
results.push(result);
|
|
693
713
|
if (!result.forkedFrom) {
|
|
694
|
-
skillsWithoutForkedFrom.push(
|
|
714
|
+
skillsWithoutForkedFrom.push(dirName);
|
|
695
715
|
}
|
|
696
716
|
}
|
|
697
717
|
const skillsWithDiffs = results.filter((r) => r.hasDiff);
|