An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# πŸ”€ ForkSync

**Auto-sync your GitHub fork repos β€” resolve conflicts with AI.**

[English](./README.md) Β· [δΈ­ζ–‡](./README_zh.md)

[![Go](https://img.shields.io/badge/Go-1.22+-00ADD8?logo=go&logoColor=white)](https://go.dev/)
[![Electron](https://img.shields.io/badge/Electron-31-47848F?logo=electron&logoColor=white)](https://www.electronjs.org/)
[![React](https://img.shields.io/badge/React-18-61DAFB?logo=react&logoColor=black)](https://react.dev/)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)


ForkSync Desktop App

---

## 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)