Implements comprehensive design pattern detection system for codebases, enabling automatic identification of common GoF patterns with confidence scoring and language-specific adaptations. **Key Features:** - 10 Design Patterns: Singleton, Factory, Observer, Strategy, Decorator, Builder, Adapter, Command, Template Method, Chain of Responsibility - 3 Detection Levels: Surface (naming), Deep (structure), Full (behavior) - 9 Language Support: Python (AST-based), JavaScript, TypeScript, C++, C, C#, Go, Rust, Java (regex-based), with Ruby/PHP basic support - Language Adaptations: Python @decorator, Go sync.Once, Rust lazy_static - Confidence Scoring: 0.0-1.0 scale with evidence tracking **Architecture:** - Base Classes: PatternInstance, PatternReport, BasePatternDetector - Pattern Detectors: 10 specialized detectors with 3-tier detection - Language Adapter: Language-specific confidence adjustments - CodeAnalyzer Integration: Reuses existing parsing infrastructure **CLI & Integration:** - CLI Tool: skill-seekers-patterns --file src/db.py --depth deep - Codebase Scraper: --detect-patterns flag for full codebase analysis - MCP Tool: detect_patterns for Claude Code integration - Output Formats: JSON and human-readable with pattern summaries **Testing:** - 24 comprehensive tests (100% passing in 0.30s) - Coverage: All 10 patterns, multi-language support, edge cases - Integration tests: CLI, codebase scraper, pattern recognition - No regressions: 943/943 existing tests still pass **Documentation:** - docs/PATTERN_DETECTION.md: Complete user guide (514 lines) - API reference, usage examples, language support matrix - Accuracy benchmarks: 87% precision, 80% recall - Troubleshooting guide and integration examples **Files Changed:** - Created: pattern_recognizer.py (1,869 lines), test suite (467 lines) - Modified: codebase_scraper.py, MCP tools, servers, CHANGELOG.md - Added: CLI entry point in pyproject.toml **Performance:** - Surface: ~200 classes/sec, <5ms per class - Deep: ~100 classes/sec, ~10ms per class (default) - Full: ~50 classes/sec, ~20ms per class **Bug Fixes:** - Fixed missing imports (argparse, json, sys) in pattern_recognizer.py - Fixed pyproject.toml dependency duplication (removed dev from optional-dependencies) **Roadmap:** - Completes C3.1 from FLEXIBLE_ROADMAP.md - Foundation for C3.2-C3.5 (usage examples, how-to guides, config patterns) Closes #117 (C3.1 Design Pattern Detection) Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
217 lines
8.1 KiB
Python
217 lines
8.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Skill Seeker MCP Server - Compatibility Shim
|
|
|
|
This file provides backward compatibility by delegating to the new server_fastmcp.py implementation.
|
|
|
|
For new installations, use server_fastmcp.py directly:
|
|
python -m skill_seekers.mcp.server_fastmcp
|
|
|
|
This shim will be deprecated in v3.0.0 (6+ months after v2.4.0 release).
|
|
"""
|
|
|
|
import sys
|
|
import warnings
|
|
|
|
# Show deprecation warning (can be disabled with PYTHONWARNINGS=ignore)
|
|
warnings.warn(
|
|
"The legacy server.py is deprecated and will be removed in v3.0.0. "
|
|
"Please update your MCP configuration to use 'server_fastmcp' instead:\n"
|
|
" OLD: python -m skill_seekers.mcp.server\n"
|
|
" NEW: python -m skill_seekers.mcp.server_fastmcp\n"
|
|
"The new server provides the same functionality with improved performance.",
|
|
DeprecationWarning,
|
|
stacklevel=2
|
|
)
|
|
|
|
# Re-export tool functions for backward compatibility with tests
|
|
try:
|
|
from skill_seekers.mcp.tools.config_tools import (
|
|
generate_config as generate_config_tool,
|
|
list_configs as list_configs_tool,
|
|
validate_config as validate_config_tool,
|
|
)
|
|
from skill_seekers.mcp.tools.scraping_tools import (
|
|
estimate_pages_tool,
|
|
scrape_docs_tool,
|
|
scrape_github_tool,
|
|
scrape_pdf_tool,
|
|
detect_patterns_tool,
|
|
run_subprocess_with_streaming,
|
|
)
|
|
from skill_seekers.mcp.tools.packaging_tools import (
|
|
package_skill_tool,
|
|
upload_skill_tool,
|
|
install_skill_tool,
|
|
)
|
|
from skill_seekers.mcp.tools.splitting_tools import (
|
|
split_config as split_config_tool,
|
|
generate_router as generate_router_tool,
|
|
)
|
|
from skill_seekers.mcp.tools.source_tools import (
|
|
fetch_config_tool,
|
|
submit_config_tool,
|
|
add_config_source_tool,
|
|
list_config_sources_tool,
|
|
remove_config_source_tool,
|
|
)
|
|
|
|
# For test compatibility - create call_tool router function
|
|
async def call_tool(name: str, arguments: dict):
|
|
"""Route tool calls to appropriate handlers (backward compatibility)."""
|
|
from mcp.types import TextContent
|
|
|
|
try:
|
|
if name == "generate_config":
|
|
return await generate_config_tool(arguments)
|
|
elif name == "estimate_pages":
|
|
return await estimate_pages_tool(arguments)
|
|
elif name == "scrape_docs":
|
|
return await scrape_docs_tool(arguments)
|
|
elif name == "package_skill":
|
|
return await package_skill_tool(arguments)
|
|
elif name == "upload_skill":
|
|
return await upload_skill_tool(arguments)
|
|
elif name == "list_configs":
|
|
return await list_configs_tool(arguments)
|
|
elif name == "validate_config":
|
|
return await validate_config_tool(arguments)
|
|
elif name == "split_config":
|
|
return await split_config_tool(arguments)
|
|
elif name == "generate_router":
|
|
return await generate_router_tool(arguments)
|
|
elif name == "scrape_pdf":
|
|
return await scrape_pdf_tool(arguments)
|
|
elif name == "scrape_github":
|
|
return await scrape_github_tool(arguments)
|
|
elif name == "fetch_config":
|
|
return await fetch_config_tool(arguments)
|
|
elif name == "submit_config":
|
|
return await submit_config_tool(arguments)
|
|
elif name == "add_config_source":
|
|
return await add_config_source_tool(arguments)
|
|
elif name == "list_config_sources":
|
|
return await list_config_sources_tool(arguments)
|
|
elif name == "remove_config_source":
|
|
return await remove_config_source_tool(arguments)
|
|
elif name == "install_skill":
|
|
return await install_skill_tool(arguments)
|
|
elif name == "detect_patterns":
|
|
return await detect_patterns_tool(arguments)
|
|
else:
|
|
return [TextContent(type="text", text=f"Unknown tool: {name}")]
|
|
except Exception as e:
|
|
return [TextContent(type="text", text=f"Error: {str(e)}")]
|
|
|
|
# For test compatibility - create a mock list_tools function
|
|
async def list_tools():
|
|
"""Mock list_tools for backward compatibility with tests."""
|
|
from mcp.types import Tool
|
|
tools = [
|
|
Tool(
|
|
name="generate_config",
|
|
description="Generate config file",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="list_configs",
|
|
description="List available configs",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="validate_config",
|
|
description="Validate config file",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="estimate_pages",
|
|
description="Estimate page count",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="scrape_docs",
|
|
description="Scrape documentation",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="scrape_github",
|
|
description="Scrape GitHub repository",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="scrape_pdf",
|
|
description="Scrape PDF file",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="package_skill",
|
|
description="Package skill into .zip",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="upload_skill",
|
|
description="Upload skill to Claude",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="install_skill",
|
|
description="Install skill",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="split_config",
|
|
description="Split large config",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="generate_router",
|
|
description="Generate router skill",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="fetch_config",
|
|
description="Fetch config from source",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="submit_config",
|
|
description="Submit config to community",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="add_config_source",
|
|
description="Add config source",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="list_config_sources",
|
|
description="List config sources",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
Tool(
|
|
name="remove_config_source",
|
|
description="Remove config source",
|
|
inputSchema={"type": "object", "properties": {}}
|
|
),
|
|
]
|
|
return tools
|
|
|
|
except ImportError:
|
|
# If imports fail, provide empty stubs
|
|
pass
|
|
|
|
# Delegate to the new FastMCP implementation
|
|
if __name__ == "__main__":
|
|
try:
|
|
from skill_seekers.mcp import server_fastmcp
|
|
# Run the new server
|
|
server_fastmcp.main()
|
|
except ImportError as e:
|
|
print(f"❌ Error: Could not import server_fastmcp: {e}", file=sys.stderr)
|
|
print("Ensure the package is installed correctly:", file=sys.stderr)
|
|
print(" pip install -e .", file=sys.stderr)
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"❌ Error running server: {e}", file=sys.stderr)
|
|
sys.exit(1)
|