feat: Unified create command + consolidated enhancement flags

This commit includes two major improvements:

## 1. Unified Create Command (v3.0.0 feature)
- Auto-detects source type (web, GitHub, local, PDF, config)
- Three-tier argument organization (universal, source-specific, advanced)
- Routes to existing scrapers (100% backward compatible)
- Progressive disclosure: 15 universal flags in default help

**New files:**
- src/skill_seekers/cli/source_detector.py - Auto-detection logic
- src/skill_seekers/cli/arguments/create.py - Argument definitions
- src/skill_seekers/cli/create_command.py - Main orchestrator
- src/skill_seekers/cli/parsers/create_parser.py - Parser integration

**Tests:**
- tests/test_source_detector.py (35 tests)
- tests/test_create_arguments.py (30 tests)
- tests/test_create_integration_basic.py (10 tests)

## 2. Enhanced Flag Consolidation (Phase 1)
- Consolidated 3 flags (--enhance, --enhance-local, --enhance-level) → 1 flag
- --enhance-level 0-3 with auto-detection of API vs LOCAL mode
- Default: --enhance-level 2 (balanced enhancement)

**Modified files:**
- arguments/{common,create,scrape,github,analyze}.py - Added enhance_level
- {doc_scraper,github_scraper,config_extractor,main}.py - Updated logic
- create_command.py - Uses consolidated flag

**Auto-detection:**
- If ANTHROPIC_API_KEY set → API mode
- Else → LOCAL mode (Claude Code)

## 3. PresetManager Bug Fix
- Fixed module naming conflict (presets.py vs presets/ directory)
- Moved presets.py → presets/manager.py
- Updated __init__.py exports

**Test Results:**
- All 160+ tests passing
- Zero regressions
- 100% backward compatible

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-02-15 14:29:19 +03:00
parent aa952aff81
commit ba1670a220
53 changed files with 10144 additions and 589 deletions

View File

@@ -30,6 +30,8 @@ except ImportError:
print("Error: PyGithub not installed. Run: pip install PyGithub")
sys.exit(1)
from skill_seekers.cli.arguments.github import add_github_arguments
# Try to import pathspec for .gitignore support
try:
import pathspec
@@ -1349,8 +1351,16 @@ Use this skill when you need to:
logger.info(f"Generated: {structure_path}")
def main():
"""C1.10: CLI tool entry point."""
def setup_argument_parser() -> argparse.ArgumentParser:
"""Setup and configure command-line argument parser.
Creates an ArgumentParser with all CLI options for the github scraper.
All arguments are defined in skill_seekers.cli.arguments.github to ensure
consistency between the standalone scraper and unified CLI.
Returns:
argparse.ArgumentParser: Configured argument parser
"""
parser = argparse.ArgumentParser(
description="GitHub Repository to Claude Skill Converter",
formatter_class=argparse.RawDescriptionHelpFormatter,
@@ -1362,36 +1372,16 @@ Examples:
""",
)
parser.add_argument("--repo", help="GitHub repository (owner/repo)")
parser.add_argument("--config", help="Path to config JSON file")
parser.add_argument("--token", help="GitHub personal access token")
parser.add_argument("--name", help="Skill name (default: repo name)")
parser.add_argument("--description", help="Skill description")
parser.add_argument("--no-issues", action="store_true", help="Skip GitHub issues")
parser.add_argument("--no-changelog", action="store_true", help="Skip CHANGELOG")
parser.add_argument("--no-releases", action="store_true", help="Skip releases")
parser.add_argument("--max-issues", type=int, default=100, help="Max issues to fetch")
parser.add_argument("--scrape-only", action="store_true", help="Only scrape, don't build skill")
parser.add_argument(
"--enhance",
action="store_true",
help="Enhance SKILL.md using Claude API after building (requires API key)",
)
parser.add_argument(
"--enhance-local",
action="store_true",
help="Enhance SKILL.md using Claude Code (no API key needed)",
)
parser.add_argument(
"--api-key", type=str, help="Anthropic API key for --enhance (or set ANTHROPIC_API_KEY)"
)
parser.add_argument(
"--non-interactive",
action="store_true",
help="Non-interactive mode for CI/CD (fail fast on rate limits)",
)
parser.add_argument("--profile", type=str, help="GitHub profile name to use from config")
# Add all github arguments from shared definitions
# This ensures the standalone scraper and unified CLI stay in sync
add_github_arguments(parser)
return parser
def main():
"""C1.10: CLI tool entry point."""
parser = setup_argument_parser()
args = parser.parse_args()
# Build config from args or file
@@ -1435,49 +1425,50 @@ Examples:
skill_name = config.get("name", config["repo"].split("/")[-1])
skill_dir = f"output/{skill_name}"
# Phase 3: Optional enhancement
if args.enhance or args.enhance_local:
logger.info("\n📝 Enhancing SKILL.md with Claude...")
# Phase 3: Optional enhancement with auto-detected mode
if getattr(args, 'enhance_level', 0) > 0:
import os
if args.enhance_local:
# Local enhancement using Claude Code
# Auto-detect mode based on API key availability
api_key = args.api_key or os.environ.get("ANTHROPIC_API_KEY")
mode = "API" if api_key else "LOCAL"
logger.info(f"\n📝 Enhancing SKILL.md with Claude ({mode} mode, level {args.enhance_level})...")
if api_key:
# API-based enhancement
try:
from skill_seekers.cli.enhance_skill import enhance_skill_md
enhance_skill_md(skill_dir, api_key)
logger.info("✅ API enhancement complete!")
except ImportError:
logger.error(
"❌ API enhancement not available. Install: pip install anthropic"
)
logger.info("💡 Falling back to LOCAL mode...")
# Fall back to LOCAL mode
from pathlib import Path
from skill_seekers.cli.enhance_skill_local import LocalSkillEnhancer
enhancer = LocalSkillEnhancer(Path(skill_dir))
enhancer.run(headless=True)
logger.info("✅ Local enhancement complete!")
else:
# LOCAL enhancement (no API key)
from pathlib import Path
from skill_seekers.cli.enhance_skill_local import LocalSkillEnhancer
enhancer = LocalSkillEnhancer(Path(skill_dir))
enhancer.run(headless=True)
logger.info("✅ Local enhancement complete!")
elif args.enhance:
# API-based enhancement
import os
api_key = args.api_key or os.environ.get("ANTHROPIC_API_KEY")
if not api_key:
logger.error(
"❌ ANTHROPIC_API_KEY not set. Use --api-key or set environment variable."
)
logger.info("💡 Tip: Use --enhance-local instead (no API key needed)")
else:
# Import and run API enhancement
try:
from skill_seekers.cli.enhance_skill import enhance_skill_md
enhance_skill_md(skill_dir, api_key)
logger.info("✅ API enhancement complete!")
except ImportError:
logger.error(
"❌ API enhancement not available. Install: pip install anthropic"
)
logger.info("💡 Tip: Use --enhance-local instead (no API key needed)")
logger.info(f"\n✅ Success! Skill created at: {skill_dir}/")
if not (args.enhance or args.enhance_local):
if getattr(args, 'enhance_level', 0) == 0:
logger.info("\n💡 Optional: Enhance SKILL.md with Claude:")
logger.info(f" Local (recommended): skill-seekers enhance {skill_dir}/")
logger.info(" or re-run with: --enhance-local")
logger.info(f" skill-seekers enhance {skill_dir}/ --enhance-level 2")
logger.info(" (auto-detects API vs LOCAL mode based on ANTHROPIC_API_KEY)")
logger.info(f"\nNext step: skill-seekers package {skill_dir}/")