{"id":51059146,"url":"https://github.com/erishen/ai-analyze","last_synced_at":"2026-06-23T00:01:41.195Z","repository":{"id":365235477,"uuid":"1139863051","full_name":"erishen/ai-analyze","owner":"erishen","description":"MCP + DeepSeek powered code analysis — Serena AST parsing, AI quality assessment, Docker auto-generation, ¥0.01-0.03 per run ","archived":false,"fork":false,"pushed_at":"2026-06-16T12:08:10.000Z","size":616,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-16T14:10:27.703Z","etag":null,"topics":["ai","ast","code-analysis","deepseek","docker","mcp","serena","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erishen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-22T14:15:09.000Z","updated_at":"2026-06-16T12:08:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/erishen/ai-analyze","commit_stats":null,"previous_names":["erishen/ai-analyze"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/erishen/ai-analyze","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Fai-analyze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Fai-analyze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Fai-analyze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Fai-analyze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erishen","download_url":"https://codeload.github.com/erishen/ai-analyze/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Fai-analyze/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34669839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ast","code-analysis","deepseek","docker","mcp","serena","static-analysis"],"created_at":"2026-06-23T00:01:39.271Z","updated_at":"2026-06-23T00:01:41.186Z","avatar_url":"https://github.com/erishen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"right\"\u003e\n  \u003ca href=\"README.zh-CN.md\"\u003e🇨🇳 中文\u003c/a\u003e\n\u003c/div\u003e\n\n# AI-Powered Code Analysis Tool\n\nAn intelligent code analysis toolkit based on **MCP (Model Context Protocol)** and **DeepSeek AI**, providing Serena code structure analysis, AI-driven quality assessment, Docker auto-generation, and end-to-end solutions.\n\n## ✨ Key Features\n\n- 🔍 **Serena Code Structure Analysis** — Multi-language support (20+ languages), intelligent symbol parsing\n- 🤖 **AI-Enhanced Analysis** — DeepSeek-powered code quality \u0026 architecture evaluation\n- 🔌 **MCP Server** — Expose analysis capabilities as MCP Tools for AI agents (Claude, Cursor, Trae, etc.)\n- 🐳 **Docker Auto-Generation** — AI-driven, intelligent containerization recommendations\n- 💰 **Ultra-Low Cost** — ~¥0.01-0.03 per full analysis\n- ⚡ **One-Click Automation** — Makefile-driven, 2-3 minutes for complete workflow\n- 📊 **Multi-Format Reports** — Markdown + JSON dual output\n- 🎯 **Smart Optimization** — 15+ optimization dimensions based on best practices\n\n## 📦 Project Structure\n\n```\n.\n├── src/                           # Source code\n│   ├── serena_client.py           # Serena MCP client\n│   ├── serena_stdio_client.py     # Stdio communication client\n│   ├── unified_analyzer.py        # Unified analysis engine\n│   ├── analysis_api.py            # Analysis REST API\n│   ├── analysis_integration.py    # Analysis integration layer\n│   ├── ast_analyzer.py            # AST-based code analyzer\n│   ├── ast_rules.py               # AST analysis rules\n│   ├── ast_visualizer.py          # AST visualization\n│   ├── benchmark.py               # Performance benchmarking\n│   ├── cache_warmer.py            # Cache pre-warming\n│   ├── config.py                  # Configuration management\n│   ├── data_store.py              # Data persistence\n│   ├── dependency_graph.py        # Dependency graph builder\n│   ├── exceptions.py              # Custom exception hierarchy\n│   ├── incremental_analyzer.py    # Incremental analysis\n│   ├── logger.py                  # Structured logging\n│   ├── memory.py                  # Memory management\n│   ├── multi_level_cache.py       # Multi-level cache system\n│   ├── performance_analyzer.py    # Performance analysis\n│   ├── plugin_system.py           # Plugin architecture\n│   ├── progress.py                # Progress tracking\n│   ├── quality_score.py           # Code quality scoring\n│   ├── report_system.py           # Report generation\n│   ├── retry.py                   # Retry with backoff\n│   ├── security_scanner.py        # Security vulnerability scanner\n│   ├── similarity.py              # Code similarity detection\n│   ├── tech_debt.py               # Technical debt tracker\n│   └── __init__.py\n├── tools/                         # Tool scripts\n│   ├── full_analyzer.py           # One-click analysis tool\n│   ├── analyze_project_multilang.py  # Multi-language analysis\n│   ├── docker_generator.py        # Docker generator\n│   ├── smart_docker_config.py     # Smart Docker configuration\n│   ├── ai_enhanced_analyzer.py    # AI-enhanced analyzer (with framework upgrade)\n│   ├── analyze_with_ai.py         # AI analysis wrapper\n│   ├── ast_analyzer_tool.py       # AST analyzer CLI tool\n│   └── clean_generated_files.py   # Cleanup tool\n├── tests/                         # Test suite (30+ test files)\n│   ├── test_serena_client.py\n│   ├── test_unified_analyzer.py\n│   ├── test_ast_analyzer.py\n│   ├── test_security_scanner.py\n│   ├── test_quality_score.py\n│   ├── test_dependency_graph.py\n│   └── ...\n├── examples/                      # Example code\n│   └── serena_example.py          # Serena usage example\n├── docs/                          # Documentation\n│   ├── FEATURES.md                # Feature overview\n│   ├── INDEX.md                   # Documentation index\n│   ├── OPTIMIZATION_HISTORY.md    # Optimization history\n│   └── QUICK_START.md             # Quick start guide\n├── scripts/                       # CI/CD scripts\n│   └── ci-verify.sh               # CI verification\n├── .github/workflows/             # GitHub Actions\n│   ├── ci.yml                     # CI pipeline\n│   └── publish.yml                # Publish pipeline\n├── reports/                       # Analysis report output\n├── pyproject.toml                 # Project config\n├── Makefile                       # Build commands (35+)\n├── .env.example                   # Environment template\n└── README.md                      # This file\n```\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n⚠️ **Two steps required before use**:\n\n1. **Download Serena MCP**\n   ```bash\n   git clone git@github.com:oraios/serena.git\n   cd serena\n   python -m venv venv\n   source venv/bin/activate  # Windows: venv\\Scripts\\activate\n   pip install -e .\n   python -m serena --version\n   ```\n\n2. **Configure DeepSeek API Key**\n   ```bash\n   cp .env.example .env\n   # Edit .env:\n   OPENAI_API_KEY=sk-your-deepseek-api-key-here\n   OPENAI_BASE_URL=https://api.deepseek.com\n   OPENAI_MODEL=deepseek-chat\n   PROJECT_PATH=/path/to/your/project\n   ```\n\n### 1. Install Dependencies\n\n#### Option 1: uv (recommended)\n\n```bash\nmake uv-install\n# Or manually:\nuv sync\nuv sync --extra dev\nuv shell\n```\n\n#### Option 2: pip\n\n```bash\nmake install\n# Or:\npip install -e .\n```\n\n**uv vs pip performance**:\n| Operation | pip | uv | Improvement |\n|-----------|-----|-----|-------------|\n| Install | ~30s | ~2s | 15x |\n| Resolve | ~10s | ~0.2s | 50x |\n| Venv create | ~5s | ~0.1s | 50x |\n\n### 2. Configure Environment\n\n```bash\ncp .env.example .env\n# Configure:\n# - PROJECT_PATH: target project path\n# - OPENAI_API_KEY: DeepSeek API key\n# - OPENAI_BASE_URL: https://api.deepseek.com\n# - OPENAI_MODEL: deepseek-chat\n```\n\n### 3. One-Click Full Analysis\n\n```bash\n# Full: Serena + AI + Docker\nmake analyze-full\n\n# Serena only\nmake analyze-full-serena\n\n# Skip AI, run Serena + Docker\nmake analyze-full-skip-ai\n\n# Skip Docker, run Serena + AI\nmake analyze-full-skip-docker\n\n# Force overwrite existing Docker config\nmake analyze-full-force\n```\n\n### 4. Individual Features\n\n```bash\n# AI enhancement only (with existing Serena report)\nmake analyze-ai-only REPORT=reports/your_report.json\n\n# Docker config only\nmake docker-generate\n\n# Build and run Docker\nmake docker-build\nmake docker-run\n```\n\n## 📋 Available Commands (35+)\n\nRun `make help` to see all commands.\n\n### 🔍 One-Click Analysis\n\n| Command | Description | AI Cost |\n|---------|-------------|---------|\n| `make analyze-full` | Full: Serena + AI + Docker | ~¥0.017 |\n| `make analyze-full-serena` | Serena only | ¥0 |\n| `make analyze-full-skip-ai` | Serena + Docker | ¥0 |\n| `make analyze-full-skip-docker` | Serena + AI | ~¥0.017 |\n| `make analyze-full-force` | Force overwrite Docker config | ~¥0.017 |\n\n### 🔍 Core Analysis\n\n| Command | Description | AI Cost |\n|---------|-------------|---------|\n| `make analyze-ai` | AI-enhanced analysis (full flow) | ~¥0.017 |\n| `make analyze-skip-ai` | Serena only | ¥0 |\n| `make analyze-ai-only` | AI enhancement on existing report | ~¥0.017 |\n| `make analyze` | Markdown report (multi-language) | ¥0 |\n| `make analyze-json` | JSON report (multi-language) | ¥0 |\n\n### 🐳 Docker Commands\n\n| Command | Description |\n|---------|-------------|\n| `make docker-check` | Check Docker config |\n| `make docker-generate` | Generate Docker config (AI) |\n| `make docker-build` | Build Docker image |\n| `make docker-run` | Run Docker container |\n| `make docker-compose-up` | Start docker-compose |\n| `make docker-compose-down` | Stop docker-compose |\n\n### 🧹 Cleanup\n\n| Command | Description |\n|---------|-------------|\n| `make clean` | Clean cache and temp files |\n| `make clean-reports` | Clean old reports |\n| `make clean-all` | Clean all generated files |\n\n### 🛠️ Development\n\n| Command | Description |\n|---------|-------------|\n| `make install` | Install dependencies |\n| `make test` | Run tests |\n| `make lint` | Lint code |\n| `make format` | Format code |\n| `make debug` | Show debug info |\n\n## 📖 Documentation\n\n- [Quick Start Guide](docs/QUICK_START.md)\n- [Feature Overview](docs/FEATURES.md)\n- [Optimization History](docs/OPTIMIZATION_HISTORY.md)\n- [Documentation Index](docs/INDEX.md)\n\n## 🔌 MCP Server\n\nai-analyze can run as an MCP Server, exposing analysis capabilities as tools for AI agents (Claude, Cursor, Trae, etc.).\n\n### Available MCP Tools\n\n| Tool | Description |\n|------|-------------|\n| `analyze_project` | Full project analysis (security, quality, dependency, AST) |\n| `scan_security` | Security vulnerability scanning |\n| `analyze_quality` | Code quality scoring (0-100, A-F grade) |\n| `analyze_ast` | Single file AST analysis (complexity, code smells) |\n| `detect_similarities` | Duplicate and similar code detection |\n| `analyze_dependencies` | Module dependency graph analysis |\n\n### Start MCP Server\n\n```bash\n# Via CLI entry point\nai-analyze-mcp\n\n# Or directly\npython -m src.mcp_server\n```\n\n### Configure in AI Agents\n\nAdd to your MCP client configuration (e.g., Claude Desktop, Cursor, Trae):\n\n```json\n{\n  \"mcpServers\": {\n    \"ai-analyze\": {\n      \"command\": \"python\",\n      \"args\": [\"-m\", \"src.mcp_server\"],\n      \"cwd\": \"/path/to/ai-analyze\"\n    }\n  }\n}\n```\n\nOr with `uv`:\n\n```json\n{\n  \"mcpServers\": {\n    \"ai-analyze\": {\n      \"command\": \"uv\",\n      \"args\": [\"run\", \"python\", \"-m\", \"src.mcp_server\"],\n      \"cwd\": \"/path/to/ai-analyze\"\n    }\n  }\n}\n```\n\n## 🎯 Feature Details\n\n### 1. Serena Multi-Language Code Analysis\n\n- **Supported Languages**: Python, JavaScript, TypeScript, Java, Go, Rust, C/C++, PHP, Ruby, Swift, and 20+ more\n- **Analysis Scope**:\n  - Directory structure and file distribution\n  - Code symbols (classes, functions, variables)\n  - Language usage ratios\n  - Project size statistics\n- **Output**: Markdown + JSON dual-format reports\n\n### 2. AI-Enhanced Deep Analysis (DeepSeek)\n\n- **Cost**: ~¥0.01-0.03 per analysis\n- **Dimensions**:\n  - Project architecture evaluation\n  - Tech stack modernization\n  - Code quality score (1-10)\n  - Potential issue identification\n  - Improvement suggestions (8-15 items)\n  - Scalability and maintainability analysis\n  - **Docker strategy recommendations**\n  - **Framework upgrade suggestions**\n- **Output**: AI-enhanced Markdown reports\n\n### 3. AI-Driven Docker Auto-Generation\n\n- **Smart Detection**:\n  - Project type (Next.js, FastAPI, Django, React, Vue, Go, Java, etc.)\n  - Database requirements (PostgreSQL, MySQL, MongoDB, Redis)\n  - Dependencies and config files\n  - Smart npm/pnpm choice based on lockfile\n- **AI Optimization**:\n  - Base image selection (alpine, slim, distroless)\n  - Multi-stage build strategy\n  - Port and security optimization\n  - Health check configuration\n  - CI/CD integration\n- **Generated Files**:\n  - `Dockerfile`, `docker-compose.yml`, `.dockerignore`\n  - `docker-build.sh`, `docker-run.sh`, `DOCKER_USAGE.md`\n\n### 4. Report Management\n\n```\nreports/\n├── project_analysis_20260125.json      # Serena raw data\n├── project_analysis_20260125.md        # Serena Markdown report\n└── project_analysis_20260125-ai.md     # AI-enhanced report\n```\n\n## 💰 Cost Analysis\n\n### Token Usage\n\n| Analysis Type | Tokens | Cost |\n|--------------|--------|------|\n| Serena Structure | 0 | ¥0 |\n| AI Code Quality | ~2,500 | ~¥0.005 |\n| AI Docker Strategy | ~5,100 | ~¥0.007 |\n| AI Framework Upgrade | ~2,500 | ~¥0.005 |\n| **Full Analysis** | **~10,100** | **~¥0.017** |\n\n### Cost Comparison\n\n| Approach | Cost | Time | Quality |\n|----------|------|------|---------|\n| Python Script | **¥0.018/run** | 2-3 min | Professional |\n| IDE + AI | Free (limited) | 15-30 min | Prompt-dependent |\n| Manual | ¥50-200 | 30-60 min | Inconsistent |\n\n## 🎬 Use Cases\n\n### Quick Project Onboarding\n```bash\nexport PROJECT_PATH=/path/to/new/project\nmake analyze-full\n```\n\n### Batch Analysis\n```bash\nfor dir in services/*/; do\n    PROJECT_PATH=\"$dir\" make analyze-full\ndone\n```\n\n### CI/CD Integration\n```yaml\n- name: Analyze code\n  run: make analyze-full\n- name: Build and test\n  run: |\n    make docker-build\n    make docker-run\n```\n\n### Code Review Assistant\n```bash\nmake analyze-full-skip-docker\n# Review AI suggestions\n```\n\n### Containerize Legacy Projects\n```bash\nexport PROJECT_PATH=/path/to/legacy/project\nmake analyze-full-skip-ai\nmake docker-build \u0026\u0026 make docker-run\n```\n\n## 🔧 Requirements\n\n- **Python**: 3.9+\n- **Serena MCP**: Latest\n- **AI API**: DeepSeek API Key (or OpenAI-compatible)\n- **OS**: macOS, Linux, Windows (WSL)\n\n## 🤝 Contributing\n\nIssues and pull requests are welcome!\n\n## 📄 License\n\nMIT\n\n---\n\n**💡 Tip**: Detailed documentation is available in the `docs/` directory.\n\n**💰 Cost Reminder**: AI analysis requires an API key — each run costs only ~¥0.01-0.03.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferishen%2Fai-analyze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferishen%2Fai-analyze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferishen%2Fai-analyze/lists"}