feat: Add --enhance-level for granular AI enhancement control
Levels: - 0 (off): No AI enhancement (default) - 1 (minimal): SKILL.md enhancement only (fast, high value) - 2 (standard): SKILL.md + Architecture + Config enhancement - 3 (full): Everything including patterns and test examples --comprehensive and --enhance-level are INDEPENDENT: - --comprehensive: Controls depth and features (full depth + all features) - --enhance-level: Controls AI enhancement level Usage examples: skill-seekers analyze --directory . --enhance-level 1 # SKILL.md AI only skill-seekers analyze --directory . --enhance # Same as level 1 skill-seekers analyze --directory . --comprehensive # All features, no AI skill-seekers analyze --directory . --comprehensive --enhance-level 2 # All features + standard AI Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -229,8 +229,7 @@ def analyze_codebase(
|
||||
extract_test_examples: bool = True,
|
||||
build_how_to_guides: bool = True,
|
||||
extract_config_patterns: bool = True,
|
||||
enhance_with_ai: bool = True,
|
||||
ai_mode: str = "auto",
|
||||
enhance_level: int = 0,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
Analyze local codebase and extract code knowledge.
|
||||
@@ -248,12 +247,25 @@ def analyze_codebase(
|
||||
extract_test_examples: Extract usage examples from test files
|
||||
build_how_to_guides: Build how-to guides from workflow examples (C3.3)
|
||||
extract_config_patterns: Extract configuration patterns from config files (C3.4)
|
||||
enhance_with_ai: Enhance patterns and examples with AI analysis (C3.6)
|
||||
ai_mode: AI enhancement mode for how-to guides (auto, api, local, none)
|
||||
enhance_level: AI enhancement level (0=off, 1=SKILL.md only, 2=+config+arch, 3=full)
|
||||
|
||||
Returns:
|
||||
Analysis results dictionary
|
||||
"""
|
||||
# Determine AI enhancement settings based on level
|
||||
# Level 0: No AI enhancement
|
||||
# Level 1: SKILL.md only (handled in main.py)
|
||||
# Level 2: Architecture + Config AI enhancement
|
||||
# Level 3: Full AI enhancement (patterns, tests, config, architecture)
|
||||
enhance_patterns = enhance_level >= 3
|
||||
enhance_tests = enhance_level >= 3
|
||||
enhance_config = enhance_level >= 2
|
||||
enhance_architecture = enhance_level >= 2
|
||||
ai_mode = "auto" if enhance_level > 0 else "none"
|
||||
|
||||
if enhance_level > 0:
|
||||
level_names = {1: "SKILL.md only", 2: "SKILL.md+Architecture+Config", 3: "full"}
|
||||
logger.info(f"🤖 AI Enhancement Level: {enhance_level} ({level_names.get(enhance_level, 'unknown')})")
|
||||
# Resolve directory to absolute path to avoid relative_to() errors
|
||||
directory = Path(directory).resolve()
|
||||
|
||||
@@ -405,7 +417,7 @@ def analyze_codebase(
|
||||
logger.info("Detecting design patterns...")
|
||||
from skill_seekers.cli.pattern_recognizer import PatternRecognizer
|
||||
|
||||
pattern_recognizer = PatternRecognizer(depth=depth, enhance_with_ai=enhance_with_ai)
|
||||
pattern_recognizer = PatternRecognizer(depth=depth, enhance_with_ai=enhance_patterns)
|
||||
pattern_results = []
|
||||
|
||||
for file_path in files:
|
||||
@@ -447,7 +459,7 @@ def analyze_codebase(
|
||||
min_confidence=0.5,
|
||||
max_per_file=10,
|
||||
languages=languages,
|
||||
enhance_with_ai=enhance_with_ai,
|
||||
enhance_with_ai=enhance_tests,
|
||||
)
|
||||
|
||||
# Extract examples from directory
|
||||
@@ -486,8 +498,8 @@ def analyze_codebase(
|
||||
try:
|
||||
from skill_seekers.cli.how_to_guide_builder import HowToGuideBuilder
|
||||
|
||||
# Create guide builder
|
||||
guide_builder = HowToGuideBuilder(enhance_with_ai=enhance_with_ai)
|
||||
# Create guide builder (uses same enhance level as test examples)
|
||||
guide_builder = HowToGuideBuilder(enhance_with_ai=enhance_tests)
|
||||
|
||||
# Build guides from workflow examples
|
||||
tutorials_dir = output_dir / "tutorials"
|
||||
@@ -505,7 +517,7 @@ def analyze_codebase(
|
||||
examples_list,
|
||||
grouping_strategy="ai-tutorial-group",
|
||||
output_dir=tutorials_dir,
|
||||
enhance_with_ai=enhance_with_ai,
|
||||
enhance_with_ai=enhance_tests,
|
||||
ai_mode=ai_mode,
|
||||
)
|
||||
|
||||
@@ -538,8 +550,8 @@ def analyze_codebase(
|
||||
# Convert to dict for enhancement
|
||||
result_dict = config_extractor.to_dict(extraction_result)
|
||||
|
||||
# AI Enhancement (if enabled)
|
||||
if enhance_with_ai and ai_mode != "none":
|
||||
# AI Enhancement (if enabled - level 2+)
|
||||
if enhance_config and ai_mode != "none":
|
||||
try:
|
||||
from skill_seekers.cli.config_enhancer import ConfigEnhancer
|
||||
|
||||
@@ -591,7 +603,7 @@ def analyze_codebase(
|
||||
logger.info("Analyzing architectural patterns...")
|
||||
from skill_seekers.cli.architectural_pattern_detector import ArchitecturalPatternDetector
|
||||
|
||||
arch_detector = ArchitecturalPatternDetector(enhance_with_ai=enhance_with_ai)
|
||||
arch_detector = ArchitecturalPatternDetector(enhance_with_ai=enhance_architecture)
|
||||
arch_report = arch_detector.analyze(directory, results["files"])
|
||||
|
||||
if arch_report.patterns:
|
||||
@@ -1147,6 +1159,19 @@ Examples:
|
||||
)
|
||||
parser.add_argument("--no-comments", action="store_true", help="Skip comment extraction")
|
||||
parser.add_argument("--verbose", action="store_true", help="Enable verbose logging")
|
||||
parser.add_argument(
|
||||
"--enhance-level",
|
||||
type=int,
|
||||
choices=[0, 1, 2, 3],
|
||||
default=0,
|
||||
help=(
|
||||
"AI enhancement level: "
|
||||
"0=off (default), "
|
||||
"1=SKILL.md only, "
|
||||
"2=SKILL.md+Architecture+Config, "
|
||||
"3=full (patterns, tests, config, architecture, SKILL.md)"
|
||||
),
|
||||
)
|
||||
|
||||
# Check for deprecated flags
|
||||
deprecated_flags = {
|
||||
@@ -1232,8 +1257,7 @@ Examples:
|
||||
extract_test_examples=not args.skip_test_examples,
|
||||
build_how_to_guides=not args.skip_how_to_guides,
|
||||
extract_config_patterns=not args.skip_config_patterns,
|
||||
enhance_with_ai=True, # Auto-disables if no API key present
|
||||
ai_mode=args.ai_mode, # NEW: AI enhancement mode for how-to guides
|
||||
enhance_level=args.enhance_level, # AI enhancement level (0-3)
|
||||
)
|
||||
|
||||
# Print summary
|
||||
|
||||
@@ -300,7 +300,14 @@ For more information: https://github.com/yusufkaraaslan/Skill_Seekers
|
||||
)
|
||||
analyze_parser.add_argument("--file-patterns", help="Comma-separated file patterns")
|
||||
analyze_parser.add_argument(
|
||||
"--enhance", action="store_true", help="Enable AI enhancement (auto-detects API or LOCAL)"
|
||||
"--enhance", action="store_true", help="Enable AI enhancement (default level 1 = SKILL.md only)"
|
||||
)
|
||||
analyze_parser.add_argument(
|
||||
"--enhance-level",
|
||||
type=int,
|
||||
choices=[0, 1, 2, 3],
|
||||
default=None,
|
||||
help="AI enhancement level: 0=off, 1=SKILL.md only (default), 2=+Architecture+Config, 3=full"
|
||||
)
|
||||
analyze_parser.add_argument("--skip-api-reference", action="store_true", help="Skip API docs")
|
||||
analyze_parser.add_argument("--skip-dependency-graph", action="store_true", help="Skip dep graph")
|
||||
@@ -548,9 +555,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||
if args.output:
|
||||
sys.argv.extend(["--output", args.output])
|
||||
|
||||
# Handle preset flags (new)
|
||||
# Handle preset flags (depth and features)
|
||||
if args.quick:
|
||||
# Quick = surface depth + skip advanced features
|
||||
# Quick = surface depth + skip advanced features + no AI
|
||||
sys.argv.extend([
|
||||
"--depth", "surface",
|
||||
"--skip-patterns",
|
||||
@@ -559,17 +566,29 @@ def main(argv: list[str] | None = None) -> int:
|
||||
"--skip-config-patterns",
|
||||
])
|
||||
elif args.comprehensive:
|
||||
# Comprehensive = full depth + all features + AI
|
||||
sys.argv.extend(["--depth", "full", "--ai-mode", "auto"])
|
||||
# Comprehensive = full depth + all features (AI level is separate)
|
||||
sys.argv.extend(["--depth", "full"])
|
||||
elif args.depth:
|
||||
sys.argv.extend(["--depth", args.depth])
|
||||
|
||||
# Determine enhance_level (independent of --comprehensive)
|
||||
# Priority: explicit --enhance-level > --enhance (level 1) > --quick (level 0) > 0
|
||||
if args.enhance_level is not None:
|
||||
enhance_level = args.enhance_level
|
||||
elif args.quick:
|
||||
enhance_level = 0 # Quick mode disables AI
|
||||
elif args.enhance:
|
||||
enhance_level = 1 # --enhance defaults to level 1
|
||||
else:
|
||||
enhance_level = 0 # Default: no AI
|
||||
|
||||
# Pass enhance_level to codebase_scraper
|
||||
sys.argv.extend(["--enhance-level", str(enhance_level)])
|
||||
|
||||
if args.languages:
|
||||
sys.argv.extend(["--languages", args.languages])
|
||||
if args.file_patterns:
|
||||
sys.argv.extend(["--file-patterns", args.file_patterns])
|
||||
if args.enhance:
|
||||
sys.argv.extend(["--ai-mode", "auto"])
|
||||
|
||||
# Pass through skip flags
|
||||
if args.skip_api_reference:
|
||||
@@ -591,14 +610,14 @@ def main(argv: list[str] | None = None) -> int:
|
||||
|
||||
result = analyze_main() or 0
|
||||
|
||||
# If --enhance or --comprehensive was used, also enhance the SKILL.md
|
||||
if result == 0 and (args.enhance or args.comprehensive):
|
||||
# Enhance SKILL.md if enhance_level >= 1
|
||||
if result == 0 and enhance_level >= 1:
|
||||
skill_dir = Path(args.output)
|
||||
skill_md = skill_dir / "SKILL.md"
|
||||
|
||||
if skill_md.exists():
|
||||
print("\n" + "=" * 60)
|
||||
print("ENHANCING SKILL.MD WITH AI")
|
||||
print(f"ENHANCING SKILL.MD WITH AI (Level {enhance_level})")
|
||||
print("=" * 60 + "\n")
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user