feat: Add discoverable 'analyze' subcommand with preset flags (Phase 1 UX improvement)

Implements Phase 1 of the codebase analysis UX improvement plan, making the
command discoverable and adding intuitive preset flags while maintaining 100%
backward compatibility.

New Features:
- Add 'analyze' subcommand to main CLI (skill-seekers analyze)
- Add --quick preset: Fast analysis (1-2 min, basic features only)
- Add --comprehensive preset: Full analysis (20-60 min, all features + AI)
- Add --enhance flag: Simple AI enhancement with auto-detection
- Improve help text with timing estimates and mode descriptions

Files Modified:
- src/skill_seekers/cli/main.py: Add analyze subcommand (lines 15, 273-311, 542-589)
- src/skill_seekers/cli/codebase_scraper.py: Add preset logic and improve help text
- tests/test_analyze_command.py: NEW - 20 comprehensive tests
- tests/test_cli_paths.py: Fix version check (2.7.0 -> 2.7.2)
- tests/test_package_structure.py: Fix 4 version checks (2.7.0 -> 2.7.2)
- README.md: Update examples to use 'analyze' command
- CLAUDE.md: Update examples to use 'analyze' command

Test Results:
- 81 tests related to Phase 1: ALL PASSING 
- 20 new tests for analyze command: ALL PASSING 
- Zero regressions introduced
- 100% backward compatibility maintained

Backward Compatibility:
- Old 'skill-seekers-codebase' command still works
- All existing flags (--depth, --ai-mode, --skip-*) still functional
- No breaking changes

Usage Examples:
  skill-seekers analyze --directory . --quick
  skill-seekers analyze --directory . --comprehensive
  skill-seekers analyze --directory . --enhance

Fixes #262 (codebase UX issues)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-01-29 21:52:46 +03:00
parent b72073a482
commit 380a71c714
7 changed files with 327 additions and 24 deletions

View File

@@ -1082,7 +1082,13 @@ Examples:
"--depth",
choices=["surface", "deep", "full"],
default="deep",
help="Analysis depth (default: deep)",
help=(
"Analysis depth: "
"surface (basic code structure, ~1-2 min), "
"deep (code + patterns + tests, ~5-10 min, DEFAULT), "
"full (everything + AI enhancement, ~20-60 min). "
"💡 TIP: Use --quick or --comprehensive presets instead for better UX!"
),
)
parser.add_argument(
"--languages", help="Comma-separated languages to analyze (e.g., Python,JavaScript,C++)"
@@ -1130,7 +1136,14 @@ Examples:
"--ai-mode",
choices=["auto", "api", "local", "none"],
default="auto",
help="AI enhancement mode for how-to guides: auto (detect best), api (Claude API), local (Claude Code CLI), none (disable) (default: auto)",
help=(
"AI enhancement mode for how-to guides: "
"auto (auto-detect: API if ANTHROPIC_API_KEY set, else LOCAL), "
"api (Claude API, requires ANTHROPIC_API_KEY), "
"local (Claude Code Max, FREE, no API key), "
"none (disable AI enhancement). "
"💡 TIP: Use --enhance flag instead for simpler UX!"
),
)
parser.add_argument("--no-comments", action="store_true", help="Skip comment extraction")
parser.add_argument("--verbose", action="store_true", help="Enable verbose logging")
@@ -1155,6 +1168,31 @@ Examples:
args = parser.parse_args()
# Handle presets (Phase 1 feature - NEW)
if hasattr(args, "quick") and args.quick and hasattr(args, "comprehensive") and args.comprehensive:
logger.error("❌ Cannot use --quick and --comprehensive together. Choose one.")
return 1
if hasattr(args, "quick") and args.quick:
# Override depth and disable advanced features
args.depth = "surface"
args.skip_patterns = True
args.skip_test_examples = True
args.skip_how_to_guides = True
args.skip_config_patterns = True
args.ai_mode = "none"
logger.info("⚡ Quick analysis mode: surface depth, basic features only (~1-2 min)")
if hasattr(args, "comprehensive") and args.comprehensive:
# Override depth and enable all features
args.depth = "full"
args.skip_patterns = False
args.skip_test_examples = False
args.skip_how_to_guides = False
args.skip_config_patterns = False
args.ai_mode = "auto"
logger.info("🚀 Comprehensive analysis mode: all features + AI enhancement (~20-60 min)")
# Set logging level
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)

View File

@@ -13,6 +13,7 @@ Commands:
github Scrape GitHub repository
pdf Extract from PDF file
unified Multi-source scraping (docs + GitHub + PDF)
analyze Analyze local codebase and extract code knowledge
enhance AI-powered enhancement (local, no API key)
enhance-status Check enhancement status (for background/daemon modes)
package Package skill into .zip file
@@ -270,6 +271,45 @@ For more information: https://github.com/yusufkaraaslan/Skill_Seekers
"--dry-run", action="store_true", help="Preview installation without making changes"
)
# === analyze subcommand ===
analyze_parser = subparsers.add_parser(
"analyze",
help="Analyze local codebase and extract code knowledge",
description="Standalone codebase analysis with C3.x features (patterns, tests, guides)",
)
analyze_parser.add_argument("--directory", required=True, help="Directory to analyze")
analyze_parser.add_argument(
"--output", default="output/codebase/", help="Output directory (default: output/codebase/)"
)
analyze_parser.add_argument(
"--quick", action="store_true", help="Quick analysis (1-2 min, basic features only)"
)
analyze_parser.add_argument(
"--comprehensive",
action="store_true",
help="Comprehensive analysis (20-60 min, all features + AI)"
)
analyze_parser.add_argument(
"--depth",
choices=["surface", "deep", "full"],
help="Analysis depth (deprecated - use --quick or --comprehensive instead)",
)
analyze_parser.add_argument(
"--languages", help="Comma-separated languages (e.g., Python,JavaScript,C++)"
)
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)"
)
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")
analyze_parser.add_argument("--skip-patterns", action="store_true", help="Skip pattern detection")
analyze_parser.add_argument("--skip-test-examples", action="store_true", help="Skip test examples")
analyze_parser.add_argument("--skip-how-to-guides", action="store_true", help="Skip guides")
analyze_parser.add_argument("--skip-config-patterns", action="store_true", help="Skip config")
analyze_parser.add_argument("--no-comments", action="store_true", help="Skip comments")
analyze_parser.add_argument("--verbose", action="store_true", help="Verbose logging")
# === install subcommand ===
install_parser = subparsers.add_parser(
"install",
@@ -499,6 +539,57 @@ def main(argv: list[str] | None = None) -> int:
sys.argv.append("--markdown")
return test_examples_main() or 0
elif args.command == "analyze":
from skill_seekers.cli.codebase_scraper import main as analyze_main
sys.argv = ["codebase_scraper.py", "--directory", args.directory]
if args.output:
sys.argv.extend(["--output", args.output])
# Handle preset flags (new)
if args.quick:
# Quick = surface depth + skip advanced features
sys.argv.extend([
"--depth", "surface",
"--skip-patterns",
"--skip-test-examples",
"--skip-how-to-guides",
"--skip-config-patterns",
])
elif args.comprehensive:
# Comprehensive = full depth + all features + AI
sys.argv.extend(["--depth", "full", "--ai-mode", "auto"])
elif args.depth:
sys.argv.extend(["--depth", args.depth])
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:
sys.argv.append("--skip-api-reference")
if args.skip_dependency_graph:
sys.argv.append("--skip-dependency-graph")
if args.skip_patterns:
sys.argv.append("--skip-patterns")
if args.skip_test_examples:
sys.argv.append("--skip-test-examples")
if args.skip_how_to_guides:
sys.argv.append("--skip-how-to-guides")
if args.skip_config_patterns:
sys.argv.append("--skip-config-patterns")
if args.no_comments:
sys.argv.append("--no-comments")
if args.verbose:
sys.argv.append("--verbose")
return analyze_main() or 0
elif args.command == "install-agent":
from skill_seekers.cli.install_agent import main as install_agent_main