{"id":51026785,"url":"https://github.com/gitstq/refactorpilot","last_synced_at":"2026-06-21T20:02:20.931Z","repository":{"id":358649230,"uuid":"1242323739","full_name":"gitstq/refactorpilot","owner":"gitstq","description":"🔧 RefactorPilot - 轻量级终端代码智能重构助手","archived":false,"fork":false,"pushed_at":"2026-05-18T10:23:53.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T12:29:07.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gitstq.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-05-18T10:20:35.000Z","updated_at":"2026-05-18T10:23:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gitstq/refactorpilot","commit_stats":null,"previous_names":["gitstq/refactorpilot"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gitstq/refactorpilot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitstq%2Frefactorpilot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitstq%2Frefactorpilot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitstq%2Frefactorpilot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitstq%2Frefactorpilot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitstq","download_url":"https://codeload.github.com/gitstq/refactorpilot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitstq%2Frefactorpilot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34623906,"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-21T02:00:05.568Z","response_time":54,"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":[],"created_at":"2026-06-21T20:02:20.115Z","updated_at":"2026-06-21T20:02:20.924Z","avatar_url":"https://github.com/gitstq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🔧 RefactorPilot\n\n**Lightweight Terminal Code Intelligent Refactoring Assistant**\n\n[![Python](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://www.python.org/)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n[![Zero Dependencies](https://img.shields.io/badge/Dependencies-Zero-orange.svg)]()\n[![Code Style](https://img.shields.io/badge/Code%20Style-PEP8-yellow.svg)]()\n\n[简体中文](./README.md) | [繁體中文](./README.zh-TW.md)\n\n\u003c/div\u003e\n\n---\n\n## 🎉 Introduction\n\nRefactorPilot is a **zero-dependency** lightweight terminal code intelligent refactoring assistant, designed for developers who pursue code quality. Based on AST (Abstract Syntax Tree) analysis technology, it can intelligently identify \"code smells\" in your code, provide professional refactoring suggestions, and even automatically generate applicable refactoring patches.\n\n### 💡 Inspiration\n\nIn daily development, we often encounter these problems:\n- Functions get longer and longer, becoming difficult to maintain\n- Code complexity keeps increasing, making testing difficult\n- Magic numbers everywhere, reducing readability\n- Want to refactor but don't know where to start\n\nRefactorPilot was born to solve these problems. It acts like an experienced code reviewer, always by your side, helping you discover issues in your code and providing improvement solutions.\n\n### ✨ Key Differentiators\n\n1. **🚀 Zero Dependencies** - Pure Python standard library implementation, no third-party dependencies required\n2. **🎯 Intelligent Smell Detection** - AST-based analysis identifies 10+ common code smells\n3. **💡 Refactoring Suggestions** - Automatically generates refactoring solutions and code patches\n4. **🖥️ TUI Interface** - Built-in terminal user interface with interactive refactoring support\n5. **🔍 Multi-dimensional Analysis** - Comprehensive analysis including cyclomatic complexity, line count, function parameters, etc.\n\n---\n\n## ✨ Core Features\n\n### 🔍 Code Smell Detection\n- **Long Functions** - Detect functions exceeding thresholds and suggest splitting\n- **High Complexity** - Identify hard-to-test code based on cyclomatic complexity\n- **Too Many Arguments** - Find functions with excessive parameters, suggest encapsulation\n- **Magic Numbers** - Identify unnamed constants, suggest extraction as named constants\n- **Unused Variables** - Discover useless variable assignments\n- **Long Lines** - Detect code lines exceeding recommended length\n- **Deep Nesting** - Identify deeply nested code blocks\n- **God Classes** - Discover large classes with too many responsibilities\n- **Primitive Obsession** - Detect primitive type combinations that should be encapsulated\n\n### 🔧 Intelligent Refactoring Suggestions\n- Generate specific refactoring solutions based on detected smells\n- Provide before/after code comparisons\n- Evaluate refactoring effort and risk levels\n- Identify quick wins (low effort, low risk)\n\n### 🖥️ Terminal Interactive Interface\n- Beautiful TUI interface with interactive operations\n- Colored output with clear information hierarchy\n- Support for file and project-level batch analysis\n- Real-time refactoring preview\n\n### 📊 Project-level Analysis\n- Scan entire project code quality\n- Generate project health reports\n- Identify high-risk files and functions\n- Support for multiple code file formats\n\n---\n\n## 🚀 Quick Start\n\n### Requirements\n- **Python**: 3.8 or higher\n- **OS**: Linux / macOS / Windows\n\n### Installation\n\n#### Option 1: Direct Installation\n```bash\n# Clone repository\ngit clone https://github.com/gitstq/refactorpilot.git\ncd refactorpilot\n\n# Install\npip install -e .\n```\n\n#### Option 2: Direct Usage\n```bash\n# No installation needed, run directly\npython -m refactorpilot --help\n```\n\n### Quick Usage\n\n#### Analyze Single File\n```bash\nrefactorpilot analyze your_code.py\n```\n\n#### Analyze Entire Project\n```bash\nrefactorpilot analyze -p ./your_project\n```\n\n#### Launch Interactive Interface\n```bash\nrefactorpilot tui\n```\n\n#### Generate Refactoring Suggestions\n```bash\nrefactorpilot suggest your_code.py\n```\n\n---\n\n## 📖 Detailed Usage Guide\n\n### CLI Commands\n\n#### `analyze` - Analyze Code\n```bash\n# Analyze single file\nrefactorpilot analyze file.py\n\n# Analyze project\nrefactorpilot analyze -p ./project\n\n# Output JSON format\nrefactorpilot analyze file.py -f json\n\n# Show only high severity issues\nrefactorpilot analyze file.py --severity high\n```\n\n#### `refactor` - Refactor Code\n```bash\n# Preview refactoring (no actual changes)\nrefactorpilot refactor file.py -d\n\n# Apply refactoring\nrefactorpilot refactor file.py --apply\n\n# Batch refactor project\nrefactorpilot refactor -p ./project --apply\n```\n\n#### `suggest` - Generate Suggestions\n```bash\nrefactorpilot suggest file.py\n```\n\n#### `tui` - Interactive Interface\n```bash\nrefactorpilot tui\n```\n\n### Configuration Options\n\nCustomize detection thresholds via environment variables or configuration:\n\n```python\n# Custom thresholds\ndetector = SmellDetector(thresholds={\n    'max_function_lines': 30,      # Max function lines\n    'max_complexity': 8,           # Max cyclomatic complexity\n    'max_arguments': 4,            # Max argument count\n    'max_line_length': 80,         # Max line length\n    'max_nesting_depth': 3,        # Max nesting depth\n    'max_class_methods': 15,       # Max class methods\n})\n```\n\n---\n\n## 💡 Design Philosophy \u0026 Roadmap\n\n### Design Principles\nRefactorPilot follows these principles:\n\n1. **Simplicity First** - Zero dependencies, works out of the box\n2. **Practicality** - Focus on most common code quality issues\n3. **Incremental Refactoring** - Support gradual improvements\n4. **Developer Friendly** - Clear output, actionable feedback\n\n### Technology Choices\n- **AST Analysis** - Python standard library `ast` module for accurate code parsing\n- **Zero Dependencies** - Only Python standard library for compatibility and lightness\n- **TUI Interface** - `curses` for cross-platform terminal interface\n- **Modular Design** - Separate analyzer, detector, suggestor for easy extension\n\n### Roadmap\n\n#### v1.1.0 (Planned)\n- [ ] JavaScript/TypeScript code analysis support\n- [ ] More refactoring patterns (extract variable, inline variable, etc.)\n- [ ] Configuration file support (YAML/JSON format)\n- [ ] Ignore rules configuration (comment markers to skip detection)\n\n#### v1.2.0 (Planned)\n- [ ] Refactoring history and rollback functionality\n- [ ] Git integration with pre-commit checks\n- [ ] HTML report generation\n- [ ] CI/CD plugins (GitHub Actions, etc.)\n\n#### v2.0.0 (Planned)\n- [ ] AI-based intelligent refactoring suggestions\n- [ ] Code similarity detection (duplicate code identification)\n- [ ] Architecture-level smell detection\n- [ ] Team collaboration features (rule sharing)\n\n### Contributing\nWe welcome contributions in:\n- 🐛 Bug fixes\n- ✨ New smell detection rules\n- 🌍 Multi-language support\n- 📚 Documentation improvements\n- 🎨 UI/UX enhancements\n\n---\n\n## 📦 Packaging \u0026 Deployment Guide\n\n### Local Development\n```bash\n# Clone repository\ngit clone https://github.com/gitstq/refactorpilot.git\ncd refactorpilot\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # Linux/macOS\n# Or: venv\\Scripts\\activate  # Windows\n\n# Install development dependencies\npip install -e .\n\n# Run tests\npython -m unittest discover tests/\n```\n\n### Build Release Package\n```bash\n# Install build tools\npip install build twine\n\n# Build\npython -m build\n\n# Upload to PyPI\npython -m twine upload dist/*\n```\n\n### Cross-platform Compatibility\n- ✅ Linux - Fully supported\n- ✅ macOS - Fully supported\n- ✅ Windows - Fully supported (TUI requires Windows 10+)\n\n---\n\n## 🤝 Contributing Guide\n\n### Submitting PRs\n1. Fork this repository\n2. Create feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit changes (`git commit -m 'feat: add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing-feature`)\n5. Create Pull Request\n\n### Commit Convention\nWe use [Conventional Commits](https://www.conventionalcommits.org/):\n- `feat:` New feature\n- `fix:` Bug fix\n- `docs:` Documentation update\n- `style:` Code style change\n- `refactor:` Code refactoring\n- `test:` Test related\n- `chore:` Build/tool related\n\n### Reporting Issues\nPlease use [GitHub Issues](https://github.com/gitstq/refactorpilot/issues) and include:\n- Issue description\n- Reproduction steps\n- Expected behavior\n- Actual behavior\n- Environment info (Python version, OS)\n\n---\n\n## 📄 License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n```\nMIT License\n\nCopyright (c) 2025 RefactorPilot Team\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n```\n\n---\n\n## 🙏 Acknowledgments\n\nThanks to these open source projects and resources:\n- [Python AST](https://docs.python.org/3/library/ast.html) - Code analysis foundation\n- [Refactoring Guru](https://refactoring.guru/) - Refactoring pattern reference\n- [Code Smells](https://sourcemaking.com/refactoring/smells) - Code smell definitions\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Made with ❤️ by RefactorPilot Team**\n\nIf this project helps you, please give us a ⭐ Star!\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitstq%2Frefactorpilot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitstq%2Frefactorpilot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitstq%2Frefactorpilot/lists"}