|
1 | | -auto-rebase — Automated Re-targeting of Feature Customizations |
| 1 | +# AutoRebase — Automated Re-targeting of Feature Customizations |
2 | 2 |
|
3 | | -Overview |
| 3 | +## Overview |
4 | 4 |
|
5 | | -auto-rebase helps re-target feature customizations when a Base SW updates. Given base-OLD, base-NEW, and feature-OLD, it produces feature-NEW with re-applied customizations, machine-readable patchsets, and a human report with traceability and validation. |
| 5 | +AutoRebase helps re-target feature customizations when a Base SW updates. Given base-OLD, base-NEW, and feature-OLD, it produces feature-NEW with re-applied customizations, machine-readable patchsets, and a human report with traceability and validation. |
6 | 6 |
|
7 | | -Quickstart (Engine CLI) |
| 7 | +## 🚀 Quick Start Options |
8 | 8 |
|
9 | | -- Optional: `bash scripts/install_tools.sh` |
10 | | -- Run the demo on included sample data: |
| 9 | +### Option 1: MCP Server (Recommended for AI Integration) |
11 | 10 |
|
12 | | -``` |
13 | | -python -m engine.cli.auto_rebase init --old-base data/sample/base-1.0 --new-base data/sample/base-1.1 --feature data/sample/feature-5.0 --req-map data/sample/requirements_map.yaml --workdir artifacts/run1 |
14 | | -python -m engine.cli.auto_rebase extract-feature --out artifacts/run1/feature_patch |
15 | | -python -m engine.cli.auto_rebase extract-base --out artifacts/run1/base_patch |
16 | | -python -m engine.cli.auto_rebase retarget --feature-patch artifacts/run1/feature_patch --base-patch artifacts/run1/base_patch --new-base data/sample/base-1.1 --out artifacts/run1/feature-5.1 |
17 | | -python -m engine.cli.auto_rebase validate --path artifacts/run1/feature-5.1 --report artifacts/run1/report.html |
18 | | -python -m engine.cli.auto_rebase finalize --path artifacts/run1/feature-5.1 --tag v5.1 --trace artifacts/run1/trace.json |
| 11 | +The MCP (Model Context Protocol) server provides AI-powered conflict resolution and is perfect for integration with AI models like Cursor. |
| 12 | + |
| 13 | +**Setup:** |
| 14 | +```bash |
| 15 | +cd mcp-server |
| 16 | +npm install |
| 17 | +npm run build |
19 | 18 | ``` |
20 | 19 |
|
21 | | -What You Get |
| 20 | +**Usage with Cursor:** |
| 21 | +1. Copy `mcp-server/cursor-mcp-config.json` to your Cursor MCP configuration |
| 22 | +2. Restart Cursor |
| 23 | +3. Use AI to call AutoRebase tools directly |
22 | 24 |
|
23 | | -- feature-NEW tree with applied changes |
24 | | -- Machine-readable ΔF and ΔB patchsets |
25 | | -- report.html and report.json (schema-validated) |
26 | | -- trace.json listing requirement IDs per patch unit |
27 | | -- Optional git tag and commit trailers |
| 25 | +**Available Tools:** |
| 26 | +- `autorebase`: Complete AutoRebase process with AI conflict resolution |
| 27 | +- `validate_repository`: Validate GitHub repositories and SHAs |
28 | 28 |
|
29 | | -Monorepo Layout |
| 29 | +See `mcp-server/README.md` for detailed MCP setup instructions. |
30 | 30 |
|
31 | | -See files under `engine/`, `server/`, `mcp-server/`, and `web/`. Adapters automatically detect external tools and fall back to robust text-based strategies if unavailable (e.g., difflib/comby heuristics). |
| 31 | +### Option 2: FastAPI Server |
32 | 32 |
|
33 | | -Environment |
| 33 | +REST API for programmatic access to AutoRebase functionality. |
34 | 34 |
|
35 | | -- Python 3.11+ recommended |
36 | | -- Node 18+ for MCP server and Next.js app |
37 | | -- Optional external tools: git, difftastic, gumtree, clang-tidy, coccinelle, dtc, yq, comby |
| 35 | +**Setup:** |
| 36 | +```bash |
| 37 | +pip install -r api/requirements.txt |
| 38 | +python api/main.py |
| 39 | +``` |
38 | 40 |
|
39 | | -Development |
| 41 | +**Usage:** |
| 42 | +```bash |
| 43 | +curl -X POST "http://localhost:8000/autorebase" \ |
| 44 | + -H "Content-Type: application/json" \ |
| 45 | + -d '{ |
| 46 | + "base_software_0": "main", |
| 47 | + "base_software_1": "main", |
| 48 | + "feature_software_0": "main", |
| 49 | + "base_repo_url": "https://github.com/user/base-repo.git", |
| 50 | + "feature_repo_url": "https://github.com/user/feature-repo.git" |
| 51 | + }' |
| 52 | +``` |
40 | 53 |
|
41 | | -- Formatting/lint: ruff, black, isort configured in `pyproject.toml` |
42 | | -- Tests: `pytest` (see `tests/`) |
43 | | -- CI: GitHub Actions in `.github/workflows/ci.yml` |
| 54 | +See `README_FASTAPI.md` for detailed API documentation. |
44 | 55 |
|
45 | | -Limitations & Fallbacks |
| 56 | +### Option 3: Engine CLI (Legacy) |
46 | 57 |
|
47 | | -- External binaries are detected at runtime. If missing, adapters degrade gracefully with warnings and use text merges. |
48 | | -- Sample adapters implement pragmatic heuristics sufficient for demo and unit tests. |
| 58 | +Command-line interface for direct AutoRebase operations. |
49 | 59 |
|
50 | | -Adding a New Adapter |
| 60 | +**Setup:** |
| 61 | +```bash |
| 62 | +bash scripts/install_tools.sh |
| 63 | +``` |
| 64 | + |
| 65 | +**Usage:** |
| 66 | +```bash |
| 67 | +python -m engine.cli.auto_rebase init --old-base data/sample/base-1.0 --new-base data/sample/base-1.1 --feature data/sample/feature-5.0 --req-map data/sample/requirements_map.yaml --workdir artifacts/run1 |
| 68 | +python -m engine.cli.auto_rebase extract-feature --out artifacts/run1/feature_patch |
| 69 | +python -m engine.cli.auto_rebase extract-base --out artifacts/run1/base_patch |
| 70 | +python -m engine.cli.auto_rebase retarget --feature-patch artifacts/run1/feature_patch --base-patch artifacts/run1/base_patch --new-base data/sample/base-1.1 --out artifacts/run1/feature-5.1 |
| 71 | +python -m engine.cli.auto_rebase validate --path artifacts/run1/feature-5.1 --report artifacts/run1/report.html |
| 72 | +python -m engine.cli.auto_rebase finalize --path artifacts/run1/feature-5.1 --tag v5.1 --trace artifacts/run1/trace.json |
| 73 | +``` |
51 | 74 |
|
52 | | -- Implement the `Adapter` Protocol in `engine/adapters/*.py`. |
53 | | -- Register detection, extraction, retargeting, apply, and validate. Prefer semantic ops; provide text fallback. |
| 75 | +## 🎯 What You Get |
| 76 | + |
| 77 | +- **feature-NEW tree** with applied changes |
| 78 | +- **Machine-readable ΔF and ΔB patchsets** |
| 79 | +- **Complete changelog** with detailed processing information |
| 80 | +- **AI-powered conflict resolution** using OpenAI |
| 81 | +- **Requirements-based resolution** respecting REQUIREMENTS_MAP.yml |
| 82 | +- **report.html and report.json** (schema-validated) |
| 83 | +- **trace.json** listing requirement IDs per patch unit |
| 84 | +- **Optional git tag and commit trailers** |
| 85 | + |
| 86 | +## 🏗️ Architecture |
| 87 | + |
| 88 | +### MCP Server (`mcp-server/`) |
| 89 | +- Model Context Protocol server for AI integration |
| 90 | +- TypeScript/Node.js implementation |
| 91 | +- Provides tools for AI models to call AutoRebase functionality |
| 92 | +- Supports local SSH authentication and GitHub token authentication |
| 93 | + |
| 94 | +### FastAPI Server (`api/`) |
| 95 | +- REST API for programmatic access |
| 96 | +- Python implementation with Pydantic models |
| 97 | +- Async/await support for concurrent operations |
| 98 | +- Comprehensive error handling and validation |
| 99 | + |
| 100 | +### Engine (`engine/`) |
| 101 | +- Core AutoRebase logic and algorithms |
| 102 | +- Adapter pattern for different file types |
| 103 | +- Fallback strategies for missing external tools |
| 104 | +- Python implementation with extensive testing |
| 105 | + |
| 106 | +### Web Interface (`web/`) |
| 107 | +- Next.js web application |
| 108 | +- User-friendly interface for AutoRebase operations |
| 109 | +- Real-time progress tracking and results visualization |
| 110 | + |
| 111 | +## 🔧 Environment Requirements |
| 112 | + |
| 113 | +- **Python**: 3.11+ recommended |
| 114 | +- **Node.js**: 18+ for MCP server and Next.js app |
| 115 | +- **OpenAI API Key**: Required for AI conflict resolution |
| 116 | +- **Git**: Required for repository operations |
| 117 | +- **Optional external tools**: difftastic, gumtree, clang-tidy, coccinelle, dtc, yq, comby |
| 118 | + |
| 119 | +## 🚀 Key Features |
| 120 | + |
| 121 | +### AI-Powered Conflict Resolution |
| 122 | +- Uses OpenAI GPT models to intelligently resolve merge conflicts |
| 123 | +- Respects REQUIREMENTS_MAP.yml for context-aware resolution |
| 124 | +- Validates resolutions with confidence scoring |
| 125 | +- Handles complex multi-file conflicts |
| 126 | + |
| 127 | +### Automatic Changelog Generation |
| 128 | +- Complete processing history with timestamps |
| 129 | +- Detailed file-by-file change tracking |
| 130 | +- Patch application success/failure logging |
| 131 | +- AI resolution statistics and validation scores |
| 132 | + |
| 133 | +### Flexible Authentication |
| 134 | +- **SSH**: Uses local SSH keys for GitHub operations |
| 135 | +- **GitHub Token**: Supports personal access tokens |
| 136 | +- **Public Repositories**: No authentication required for read operations |
| 137 | +- **Local Credentials**: Falls back to system Git configuration |
| 138 | + |
| 139 | +### Robust Error Handling |
| 140 | +- Graceful degradation when external tools are missing |
| 141 | +- Comprehensive validation of inputs and outputs |
| 142 | +- Detailed error messages with troubleshooting guidance |
| 143 | +- Fallback strategies for edge cases |
| 144 | + |
| 145 | +## 🧪 Development |
| 146 | + |
| 147 | +- **Formatting/lint**: ruff, black, isort configured in `pyproject.toml` |
| 148 | +- **Tests**: `pytest` (see `tests/`) |
| 149 | +- **CI**: GitHub Actions in `.github/workflows/ci.yml` |
| 150 | +- **Type Safety**: TypeScript for MCP server, Pydantic for Python APIs |
| 151 | + |
| 152 | +## 🔒 Security & Privacy |
| 153 | + |
| 154 | +- **Local Processing**: All operations happen on your machine |
| 155 | +- **No Data Storage**: No sensitive data is stored or transmitted |
| 156 | +- **Secure Authentication**: Multiple authentication methods supported |
| 157 | +- **API Key Management**: Secure handling of OpenAI and GitHub tokens |
| 158 | +- **Public Repository Focus**: Designed for open-source workflows |
| 159 | + |
| 160 | +## 📚 Documentation |
| 161 | + |
| 162 | +- **MCP Server**: `mcp-server/README.md` - AI integration guide |
| 163 | +- **FastAPI**: `README_FASTAPI.md` - REST API documentation |
| 164 | +- **Cursor Setup**: `mcp-server/CURSOR_SETUP.md` - Cursor AI integration |
| 165 | +- **Engine**: `engine/README.md` - Core algorithm documentation |
| 166 | + |
| 167 | +## 🤝 Contributing |
| 168 | + |
| 169 | +1. Fork the repository |
| 170 | +2. Create a feature branch |
| 171 | +3. Make your changes |
| 172 | +4. Test thoroughly (unit tests + integration tests) |
| 173 | +5. Submit a pull request |
| 174 | + |
| 175 | +## 📄 License |
| 176 | + |
| 177 | +MIT License - see LICENSE file for details. |
54 | 178 |
|
0 commit comments