# Capability Discovery System # Automatically discovers and includes capability Makefiles # Find all capability directories that contain Makefiles CAPABILITY_DIRS := $(dir $(wildcard capabilities/*/Makefile)) CAPABILITY_MAKEFILES := $(foreach dir,$(CAPABILITY_DIRS),$(dir)Makefile) # DO NOT include capability Makefiles directly to avoid target conflicts # Instead, use delegation patterns below for accessing capability targets # Capability discovery and delegation system .PHONY: capabilities-list capabilities-list: ## List all available capabilities @echo "๐Ÿงฉ Available Capabilities:" @echo "==========================" @for dir in $(CAPABILITY_DIRS); do \ if [ -f "$$dir/Makefile" ]; then \ echo ""; \ capability=$$(basename $$dir); \ echo "๐Ÿ“ฆ $$capability"; \ echo " Location: $$dir"; \ if [ -f "$$dir/README.md" ]; then \ desc=$$(head -5 "$$dir/README.md" | grep -E "^[A-Z].*" | head -1 || echo "No description"); \ echo " Description: $$desc"; \ fi; \ echo " Makefile: Available"; \ fi; \ done @echo "" @echo "Use 'make capabilities-help' to see all capability targets" .PHONY: capabilities-help capabilities-help: ## Show help for all capabilities @echo "๐Ÿงฉ All Capability Targets:" @echo "==========================" @for dir in $(CAPABILITY_DIRS); do \ if [ -f "$$dir/Makefile" ]; then \ echo ""; \ capability=$$(basename $$dir); \ echo "๐Ÿ“ฆ $$capability capability:"; \ echo ""; \ $(MAKE) -C "$$dir" help 2>/dev/null | grep -E "^ " || echo " No help available"; \ fi; \ done .PHONY: capabilities-install capabilities-install: ## Install all capabilities @echo "๐Ÿ”ง Installing all capabilities..." @for dir in $(CAPABILITY_DIRS); do \ if [ -f "$$dir/pyproject.toml" ]; then \ capability=$$(basename $$dir); \ echo "Installing $$capability..."; \ pip install -e "$$dir" || echo "Failed to install $$capability"; \ fi; \ done .PHONY: capabilities-test capabilities-test: ## Run tests for all capabilities @echo "๐Ÿงช Testing all capabilities..." @for dir in $(CAPABILITY_DIRS); do \ if [ -f "$$dir/Makefile" ]; then \ capability=$$(basename $$dir); \ echo ""; \ echo "Testing $$capability..."; \ $(MAKE) -C "$$dir" test 2>/dev/null || echo "No tests or test failed for $$capability"; \ fi; \ done # Create delegation targets for common patterns # This allows calling capability targets directly from main makefile # Release management delegation (special handling since it's commonly used) .PHONY: release-% release-%: @if [ -f "capabilities/release-management/Makefile" ]; then \ $(MAKE) -C capabilities/release-management $@; \ else \ echo "โŒ Release management capability not found"; \ exit 1; \ fi # Generic capability delegation pattern # Format: capability-name-target-name define CAPABILITY_DELEGATION .PHONY: $(1)-% $(1)-%: @if [ -f "capabilities/$(1)/Makefile" ]; then \ target_name=$$$$(echo "$$@" | sed 's/$(1)-//'); \ $(MAKE) -C "capabilities/$(1)" "$$$$target_name" || \ $(MAKE) -C "capabilities/$(1)" "$(1)-$$$$target_name" 2>/dev/null || \ echo "โŒ Target '$$$$target_name' not found in $(1) capability"; \ else \ echo "โŒ Capability '$(1)' not found or has no Makefile"; \ exit 1; \ fi endef # Generate delegation targets for each capability $(foreach cap,$(patsubst capabilities/%/,%,$(CAPABILITY_DIRS)),$(eval $(call CAPABILITY_DELEGATION,$(cap)))) # Show available capability targets .PHONY: capabilities-targets capabilities-targets: ## Show all available capability targets @echo "๐ŸŽฏ Available Capability Targets:" @echo "================================" @for dir in $(CAPABILITY_DIRS); do \ if [ -f "$$dir/Makefile" ]; then \ capability=$$(basename $$dir); \ echo ""; \ echo "๐Ÿ“ฆ $$capability:"; \ $(MAKE) -C "$$dir" -qp 2>/dev/null | \ grep -E "^[a-zA-Z][^:]*:.*##" | \ sed 's/:.*##//' | \ while read target; do \ echo " $$capability-$$target"; \ echo " $@"; \ done || echo " No documented targets"; \ fi; \ done # Capability status check .PHONY: capabilities-status capabilities-status: ## Show status of all capabilities @echo "๐Ÿ“Š Capability Status:" @echo "====================" @for dir in $(CAPABILITY_DIRS); do \ capability=$$(basename $$dir); \ echo ""; \ echo "๐Ÿ“ฆ $$capability:"; \ if [ -f "$$dir/Makefile" ]; then \ echo " โœ… Makefile: Available"; \ else \ echo " โŒ Makefile: Missing"; \ fi; \ if [ -f "$$dir/pyproject.toml" ]; then \ echo " โœ… Package: Available"; \ if pip show "$$(echo $$capability | tr '-' '_')" >/dev/null 2>&1 || \ pip show "$$capability" >/dev/null 2>&1; then \ echo " โœ… Installed: Yes"; \ else \ echo " โŒ Installed: No"; \ fi; \ else \ echo " โŒ Package: Not available"; \ fi; \ if [ -f "$$dir/README.md" ]; then \ echo " โœ… Documentation: Available"; \ else \ echo " โŒ Documentation: Missing"; \ fi; \ done # Auto-complete help integration .PHONY: help-capabilities help-capabilities: ## Show capability system help @echo "" @echo "๐Ÿงฉ Capability System:" @echo " capabilities-list List all available capabilities" @echo " capabilities-help Show help for all capabilities" @echo " capabilities-status Show status of all capabilities" @echo " capabilities-install Install all capabilities" @echo " capabilities-test Test all capabilities" @echo " capabilities-targets Show all available capability targets" @echo "" @echo "๐ŸŽฏ Capability Delegation:" @echo " Use 'capability-name-target' to call targets from capabilities" @echo " Example: 'make release-management-status' calls status from release-management" @echo " Special: release-* targets are delegated to release-management capability" @echo "" # Export capability information for use by main Makefile CAPABILITIES_FOUND := $(words $(CAPABILITY_DIRS)) export CAPABILITIES_FOUND export CAPABILITY_DIRS