|
| 1 | +# AI Sync |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <img src="assets/logo.svg" alt="AI Sync Logo" width="100" /> |
| 5 | +</p> |
| 6 | + |
| 7 | +Centralized management tool for AI configuration files across Git repositories and local AI services. Keep files like `CLAUDE.md`, `.cursor/`, `GEMINI.md` synced across all your repos, and sync local AI service settings (e.g., `~/.claude/` for Claude Code) — all without committing them. |
| 8 | + |
| 9 | +> [!WARNING] |
| 10 | +> Under development, use at your own risk. |
| 11 | +
|
| 12 | +## How it works |
| 13 | + |
| 14 | +- A **central store** (a separate git repo you choose) holds all AI config files, organized by repository and service |
| 15 | +- A **sync engine** watches for changes on both sides and syncs automatically using **git 3-way merge** — non-conflicting changes are auto-merged |
| 16 | +- **AI service configs** (e.g., Claude Code's `~/.claude/`) can be synced with predefined file patterns — no manual path browsing needed |
| 17 | +- **Multi-machine support** — each machine gets a unique identity; a git-tracked `machines.json` maps repo paths per machine, so the same store works across machines with different directory layouts. Repos are auto-linked on startup |
| 18 | +- A **web UI** lets you manage repos, services, edit files, and resolve conflicts |
| 19 | +- AI files are automatically **git-ignored** and **removed from git tracking** in target repos |
| 20 | +- **App code and user data are fully separated** — update the tool without affecting your data |
| 21 | + |
| 22 | +## Quick Start |
| 23 | + |
| 24 | +**Prerequisites:** Node.js 22+, pnpm 10+ |
| 25 | + |
| 26 | +```bash |
| 27 | +# Install |
| 28 | +pnpm install |
| 29 | + |
| 30 | +# Build |
| 31 | +pnpm build |
| 32 | + |
| 33 | +# Run (production) |
| 34 | +pnpm start |
| 35 | +``` |
| 36 | + |
| 37 | +Open http://localhost:2703 |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +1. On first launch, the UI shows a **setup screen** — pick a directory for your data store |
| 42 | +2. This directory becomes a Git repo containing all your AI config files and the SQLite database |
| 43 | +3. Click **Add Repository** to register a local git repo |
| 44 | +4. The tool scans for AI config files, copies them to the store, and starts syncing |
| 45 | +5. AI files are added to the target repo's `.gitignore` and removed from git tracking |
| 46 | +6. Click **Add Service** to sync local AI service configs (e.g., Claude Code) — the tool auto-detects installed services and uses predefined file patterns |
| 47 | +7. Edit files in the UI or directly in the repo/service directory — changes sync both ways |
| 48 | +8. Conflicts (both sides changed) appear in the detail page for resolution |
| 49 | + |
| 50 | +### Data directory structure |
| 51 | + |
| 52 | +``` |
| 53 | +<your-data-dir>/ # Git repo (you chose this path) |
| 54 | +├── machines.json # Machine-to-path mappings (git-tracked) |
| 55 | +├── repos/ |
| 56 | +│ ├── _default/ # Template for new repos |
| 57 | +│ ├── my-project/ # AI files for my-project |
| 58 | +│ └── another-project/ # AI files for another-project |
| 59 | +├── services/ |
| 60 | +│ └── claude-code/ # Claude Code config files |
| 61 | +└── .db/ |
| 62 | + └── ai-sync.db # SQLite database (git-ignored) |
| 63 | +``` |
| 64 | + |
| 65 | +### Override data directory |
| 66 | + |
| 67 | +```bash |
| 68 | +DATA_DIR=/path/to/data pnpm start |
| 69 | +``` |
| 70 | + |
| 71 | +## Setting up on a new machine |
| 72 | + |
| 73 | +```bash |
| 74 | +git clone <this-repo-url> |
| 75 | +cd ai-sync |
| 76 | +pnpm install && pnpm build && pnpm start |
| 77 | +``` |
| 78 | + |
| 79 | +On the setup screen, point to your existing data directory (clone your store repo first if needed). |
| 80 | + |
| 81 | +The app will automatically assign a machine identity and **auto-link** any repos that already have a path mapping for this machine in `machines.json`. Repos that can't be auto-linked appear as **Unlinked Repositories** on the dashboard — click **Link** to map them to local paths, **Auto-link All** to link everything at once, or the **trash icon** to remove repos you no longer need. |
| 82 | + |
| 83 | +## Development |
| 84 | + |
| 85 | +```bash |
| 86 | +# Start both server and UI with hot reload |
| 87 | +pnpm dev # open http://localhost:5173 |
| 88 | + |
| 89 | +# Or run them separately |
| 90 | +pnpm dev:server # Fastify on :2703 |
| 91 | +pnpm dev:ui # Vite on :5173 (proxies API to :2703) |
| 92 | + |
| 93 | +# Test |
| 94 | +pnpm test # Run all tests |
| 95 | + |
| 96 | +# Format & lint |
| 97 | +pnpm format # Format all code with Prettier |
| 98 | +pnpm format:check # Check formatting without writing |
| 99 | +pnpm lint # Run ESLint on all packages |
| 100 | +pnpm lint:fix # Auto-fix ESLint issues |
| 101 | +``` |
| 102 | + |
| 103 | +### Reset to fresh state |
| 104 | + |
| 105 | +To return to the initial setup screen (e.g. to pick a different data directory): |
| 106 | + |
| 107 | +- **Via the UI**: Click the **Change** button next to the data directory path on the Dashboard |
| 108 | +- **Via the command line**: |
| 109 | + |
| 110 | + ```bash |
| 111 | + rm ~/.ai-sync/config.json |
| 112 | + ``` |
| 113 | + |
| 114 | +This only removes the pointer to your data directory — it does **not** delete your data files. |
| 115 | + |
| 116 | +To fully wipe everything (data directory + config): |
| 117 | + |
| 118 | +```bash |
| 119 | +rm ~/.ai-sync/config.json |
| 120 | +rm -rf /path/to/your/data-dir # the directory you chose during setup |
| 121 | +``` |
| 122 | + |
| 123 | +## Tech Stack |
| 124 | + |
| 125 | +| Layer | Technology | |
| 126 | +| -------- | ----------------------------------------------------------- | |
| 127 | +| Backend | Fastify 5, TypeScript, better-sqlite3, chokidar, simple-git | |
| 128 | +| Frontend | React 19, Vite, shadcn/ui, Tailwind CSS, CodeMirror 6 | |
| 129 | +| Monorepo | pnpm workspace (`packages/server` + `packages/ui`) | |
| 130 | + |
| 131 | +## Project Structure |
| 132 | + |
| 133 | +``` |
| 134 | +├── packages/server/ # Fastify backend + sync engine |
| 135 | +├── packages/ui/ # React SPA |
| 136 | +├── dev-docs/ # Documentation for development |
| 137 | +└── docs/ # Documentation for the project |
| 138 | +``` |
| 139 | + |
| 140 | +User data is stored externally in the directory you choose during setup (config saved at `~/.ai-sync/config.json`). |
| 141 | + |
| 142 | +See [docs/intro.md](docs/intro.md) for supported AI file patterns and services, [docs/how-to.md](docs/how-to.md) for a detailed usage guide, and [dev-docs/project.md](dev-docs/project.md) for development documentation. |
| 143 | + |
| 144 | +## License |
| 145 | + |
| 146 | +[MIT](LICENSE) |
0 commit comments