https://github.com/loongxjin/forksync
π Auto-sync GitHub fork repos with upstream. Resolve merge conflicts using AI agents (Claude Code, OpenCode, Droid, Codex). Desktop app (Electron) + CLI.
https://github.com/loongxjin/forksync
ai-agent auto-sync github-fork merge-conflict
Last synced: about 2 months ago
JSON representation
π Auto-sync GitHub fork repos with upstream. Resolve merge conflicts using AI agents (Claude Code, OpenCode, Droid, Codex). Desktop app (Electron) + CLI.
- Host: GitHub
- URL: https://github.com/loongxjin/forksync
- Owner: loongxjin
- Created: 2026-04-13T07:17:08.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-26T16:13:57.000Z (about 2 months ago)
- Last Synced: 2026-04-26T17:27:44.414Z (about 2 months ago)
- Topics: ai-agent, auto-sync, github-fork, merge-conflict
- Language: Go
- Homepage:
- Size: 11.9 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# π ForkSync
**Auto-sync your GitHub fork repos β resolve conflicts with AI.**
[English](./README.md) Β· [δΈζ](./README_zh.md)
[](https://go.dev/)
[](https://www.electronjs.org/)
[](https://react.dev/)
[](./LICENSE)
---
## Why ForkSync?
Maintaining forked repositories is tedious. Upstream authors keep shipping changes, and every sync risks merge conflicts. You either:
- β **Forget to sync** β your fork falls behind, missing bug fixes and features
- β **Resolve conflicts manually** β reading `<<<<<<<` markers for hours
- β **Give up and re-fork** β losing your local modifications
**ForkSync solves this.** It automatically syncs your forks and uses AI coding agents (Claude Code, OpenCode, Droid, Codex) to resolve merge conflicts β so you never have to touch conflict markers again.
## β¨ Key Features
| Feature | Description |
|---------|-------------|
| π **Auto Sync** | Periodically fetches and merges upstream changes (configurable interval) |
| π€ **AI Conflict Resolution** | Delegates merge conflicts to AI agents (Claude Code, OpenCode, Droid, Codex) |
| π₯οΈ **Desktop App** | Polished Electron GUI β dashboard, conflict viewer, settings |
| β¨οΈ **CLI** | Full-featured command-line tool for terminal workflows |
| π **Directory Scanner** | Recursively scans any directory to discover and batch-add fork repos |
| π **Sync History** | SQLite-backed history with filters, AI-generated summaries, and cleanup |
| π **System Notifications** | macOS native alerts on sync success, conflicts, or errors |
| π₯οΈ **IDE Integration** | Open repos directly in VSCode, Cursor, or Trae |
| π **i18n** | Multi-language interface |
| βοΈ **Flexible Strategies** | `preserve_ours` / `preserve_theirs` / `balanced` / `agent_resolve` |
---
## π¦ Install
### Download
Grab the latest release for your platform:
| Platform | Format | Link |
|----------|--------|------|
| macOS | `.dmg` | [Releases](https://github.com/loongxjin/forksync/releases) |
| Linux | `.AppImage` | [Releases](https://github.com/loongxjin/forksync/releases) |
| Windows | `.exe` (NSIS) | [Releases](https://github.com/loongxjin/forksync/releases) |
### Build from Source
```bash
git clone https://github.com/loongxjin/forksync.git
cd forksync
# Full build (Go engine + Electron app)
make build
# Output: app/dist/
```
### CLI Only
```bash
cd engine && go build -o forksync . && ./forksync --help
```
---
## π Quick Start
### 1. Configure GitHub Token (Recommended)
```bash
mkdir -p ~/.forksync
```
Edit `~/.forksync/config.yaml`:
```yaml
github:
token: "ghp_your_token_here"
```
> Token is optional but recommended β it enables automatic upstream detection via GitHub API.
### 2. Add Repos
```bash
# Add a single repo
forksync add ~/projects/my-fork
# Scan a directory to batch-discover fork repos
forksync scan ~/projects
```
### 3. Sync
```bash
# Sync all repos
forksync sync --all
# Sync a specific repo
forksync sync my-fork
# Start background sync service (every 30 min)
forksync serve
```
### 4. Resolve Conflicts with AI
```bash
# Resolve conflicts using AI (interactive)
forksync resolve my-fork
# Use a specific agent, auto-commit
forksync resolve my-fork --agent claude --no-confirm
```
### 5. Launch Desktop App
```bash
cd app && npm install && npm run dev
```
---
## π€ AI Conflict Resolution
This is the core feature that sets ForkSync apart. When a sync produces merge conflicts, ForkSync can automatically delegate resolution to an AI coding agent:
```
βββββββββββββββ conflict βββββββββββββββββ resolve ββββββββββββββββββ
β Upstream β βββββββββββββββΆ β ForkSync β βββββββββββββΆβ AI Agent β
β Change β β detects β β (Claude/etc.) β
βββββββββββββββ β conflict β βββββββββ¬βββββββββ
βββββββββββββββββ β
β resolved
βΌ
βββββββββββββββββ ββββββββββββββββββ
β ForkSync β βββββββββββββ Verify & β
β commits β commit β Commit β
βββββββββββββββββ ββββββββββββββββββ
```
**Supported Agents:**
| Agent | Binary | Auto-detected |
|-------|--------|:------------:|
| Claude Code | `claude` | β
|
| OpenCode | `opencode` | β
|
| Droid | `droid` | β
|
| Codex | `codex` | β
|
Agents are auto-discovered via `PATH`. Set a preferred agent in config:
```yaml
agent:
preferred: "claude"
conflict_strategy: "agent_resolve"
```
**Resolution strategies:**
| Strategy | Behavior |
|----------|----------|
| `preserve_ours` | Keep local changes, accept non-conflicting upstream |
| `preserve_theirs` | Prefer upstream changes |
| `balanced` | Smart merge preserving both sides |
| `agent_resolve` | Delegate to AI agent |
---
## π₯οΈ Desktop App
Built with **Electron** + **React** + **TypeScript** + **Tailwind CSS** + **shadcn/ui**.
| Page | Description |
|------|-------------|
| **Dashboard** | Overview: synced/conflict counts, recent activity, agent status |
| **Repos** | Add, scan, sync, remove repositories |
| **Conflicts** | List repos with conflicts, resolve via agents |
| **Conflict Detail** | Diff viewer, agent summary, accept/reject resolution |
| **History** | Sync timeline with filters and cleanup |
| **Settings** | General settings, agent config, IDE preferences, theme |
**Architecture:**
```
βββββββββββββββββββββββββββββββββββββ
β Electron UI (React) β
β Dashboard Β· Repos Β· Conflicts β
β History Β· Settings Β· Detail β
βββββββββββββββββ¬ββββββββββββββββββββ
β IPC (contextBridge)
βββββββββββββββββΌββββββββββββββββββββ
β EngineClient (TypeScript) β
β Spawns Go binary, parses JSON β
βββββββββββββββββ¬ββββββββββββββββββββ
β --json flag
βββββββββββββββββΌββββββββββββββββββββ
β Go CLI Engine (Cobra) β
β add Β· sync Β· resolve Β· serve β
β agent Β· config Β· history β
βββββββββββββββββββββββββββββββββββββ
```
---
## β¨οΈ CLI Reference
All commands support `--json` for structured output.
```bash
# Repository management
forksync add [--upstream ] # Add repo
forksync remove # Remove from tracking
forksync scan # Batch-discover fork repos
# Sync
forksync sync [--all | ] # Sync repos
forksync serve [--interval 15m] # Background sync service
forksync status # Show all repo statuses
# AI conflict resolution
forksync resolve [--agent claude] [--no-confirm] [--accept] [--reject]
# Agent management
forksync agent list # Detect installed agents
forksync agent sessions # List active sessions
forksync agent cleanup # Remove expired sessions
# Configuration
forksync config get # Show all config
forksync config set # Set config value
forksync config keys # List available keys
# History
forksync history [--limit 20] [--cleanup [--keep-days 30]]
```
---
## βοΈ Configuration
**Location:** `~/.forksync/config.yaml`
```yaml
sync:
default_interval: "30m"
sync_on_startup: true
agent:
preferred: "claude"
priority: [claude, opencode, droid, codex]
timeout: "10m"
conflict_strategy: "agent_resolve"
confirm_before_commit: true
session_ttl: "24h"
github:
token: ""
notification:
enabled: true
proxy:
enabled: false
url: ""
```
**Data files:**
| Path | Purpose |
|------|---------|
| `~/.forksync/config.yaml` | User configuration |
| `~/.forksync/repos.json` | Managed repository list |
| `~/.forksync/sessions/.json` | Agent session records |
| `~/.forksync/db/forksync.db` | SQLite sync history |
| `~/.forksync/logs/sync-*.log` | Daily-rotated log files |
---
## ποΈ Project Structure
```
forksync/
βββ engine/ # Go CLI engine
β βββ cmd/ # Cobra commands
β βββ internal/
β β βββ agent/ # AI agent adapters (Claude, OpenCode, Droid, Codex)
β β β βββ session/ # Session lifecycle management
β β βββ config/ # Viper-based YAML config
β β βββ conflict/ # Merge conflict detection
β β βββ git/ # Git operations (go-git + CLI fallback)
β β βββ github/ # GitHub REST API client
β β βββ history/ # SQLite sync history store
β β βββ logger/ # File logger with daily rotation
β β βββ notify/ # macOS system notifications
β β βββ repo/ # Repository JSON store (thread-safe)
β β βββ scheduler/ # Background sync scheduler
β β βββ sync/ # Core sync pipeline
β βββ pkg/types/ # Shared types
β
βββ app/ # Electron desktop app
β βββ src/main/ # Electron main process + EngineClient
β βββ src/preload/ # Context bridge (window.api)
β βββ src/renderer/ # React UI (pages, components, contexts)
β
βββ build/ # Build scripts
βββ docs/ # Documentation
```
---
## π§ͺ Testing
```bash
cd engine && go test ./... -v
```
**146 tests** across 15 test files β covering sync pipeline, agent adapters, session management, git operations, conflict detection, config, history, and more.
---
## π οΈ Development
See [Development Guide](./docs/DEVELOPMENT.md) for setup instructions and architecture details.
## π License
[MIT](./LICENSE)