hduc-le/agy-sync
About
Safe, zero-dependency bidirectional conversation sync between Antigravity CLI and Antigravity Desktop
Developer ToolsMeasured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalagy-sync
Safe, zero-dependency, bidirectional conversation synchronization between Antigravity CLI (~/.gemini/antigravity-cli) and Antigravity Desktop (~/.gemini/antigravity).
Why agy-sync?
Antigravity CLI and Antigravity Desktop store conversations in separate local stores (~/.gemini/antigravity-cli and ~/.gemini/antigravity) with distinct trajectory source enums, summary caches, project bindings, and brain paths. Naively copying files between them breaks protobuf length prefixes, drops WAL-mode SQLite transactions, loses nested subagents, or causes the CLI watcher to hide migrated sessions.
agy-sync handles all of these safely:
- Interactive Terminal UI (zero dependencies) — Run
agy-sync(oragy-sync tui) in any TTY or SSH session to browse conversations, inspect subagents and workspace URIs, search/filter, pick target Desktop projects, preview dry-runs, and apply selected sessions with interactive safety toggles. - Dry-run by default —
agy-sync plan,agy-sync sync, andagy-sync tuimake zero filesystem writes unless you explicitly pass--applyor confirm in the Apply modal. - Strictly read-only on source stores — Every source SQLite database is opened with
file:<path>?mode=roandPRAGMA query_only = ON. Original conversations are never modified or deleted. - WAL-safe SQLite copying — Uses
sqlite3.Connection.backup()into a temporary sibling file, verifiesPRAGMA integrity_check == "ok", and atomically swaps viaos.replace(). - Wire-safe protobuf rewriting — Recursively parses and re-serializes protobuf messages so variable-length path rewrites (
antigravity-cli/brain/<old>↔antigravity/brain/<new>) recompute all enclosing varint length prefixes cleanly. - Full recursive subagent trees — Discovers and syncs multi-level subagents (
depth 0 → 1 → 2+), remappingparent_conversation_id,conversation_parents,conversations_fts,brain/, andannotations/*.pbtxt. - Two-layer anti-loop & fast-forward back-sync — Uses deterministic UUID5 mapping (
antigravity-desktop:<cid>/antigravity-cli:<cid>), a persistent ledger (~/.gemini/agy-sync/state.json), and stateless reverse-map detection so syncingCLI → Desktop → CLInever creates duplicate loops (A''), while safely fast-forwarding edits made on a mirror back to its origin when the origin is untouched. - Daemon safety guardrails — Detects active Desktop and CLI daemons via
daemon/hub_*.jsonand refuses direct SQLite/proto writes while the target daemon is running (supporting--live-rpcfor Desktop or--allow-livefor CLI). - Automatic pre-write backups — Snapshots target
conversation_summaries.db, summary proto caches, and any existingconversations/<dst_cid>.dbabout to be updated under~/.gemini/agy-sync/backups/<timestamp>/before applying writes.
Installation
Requires Python 3.10+ (pure standard library at runtime — no third-party dependencies).
With uv (recommended)
uv tool install git+https://github.com/hduc-le/agy-sync.git
With pipx
pipx install git+https://github.com/hduc-le/agy-sync.git
From a local clone
git clone https://github.com/hduc-le/agy-sync.git
cd agy-sync
uv tool install --editable .
Verify the installation:
agy-sync --version
agy-sync --help
Quick Start
Interactive TUI (recommended)
Run agy-sync directly in an interactive terminal (or explicitly agy-sync tui):
agy-sync
agy-sync tui --direction cli-to-desktop
The TUI opens in read-only browse mode with zero writes until you confirm in the Apply modal (x → y). It works over SSH on Linux servers as well as macOS and Windows, adapting automatically between side-by-side split pane (width >= 106) and compact stacked layout (80x24).
| Key | Action |
|---|---|
↑ / ↓ or k / j |
Move highlight (PgUp/PgDn, g/G to jump) |
Space / a / c |
Toggle select / select all actionable / clear selection |
1 / 2 / 3 |
Switch direction: Both / CLI→Desktop / Desktop→CLI |
f or Tab |
Cycle filter: All / Actionable / Back-sync / Synced |
/ |
Live search by title, UUID, project, or workspace |
p |
Open Desktop Project Picker override |
d or Enter |
Dry-Run Preview modal (zero writes) |
x |
Confirm Apply modal (toggles: l Live RPC, w Allow Live CLI, F Force, b Backup) |
r |
Refresh stores, daemon status, and sync plan |
? / q |
Help overlay / Quit |
1. Inspect your local stores (read-only)
agy-sync status
agy-sync projects
status shows store paths, active Desktop/CLI daemons, root/subagent session counts, legacy .pb files, and ledger stats.
2. Preview what would be synced (zero writes)
agy-sync plan --direction both
agy-sync plan --direction cli-to-desktop
agy-sync plan --direction desktop-to-cli
3. Sync from CLI to Desktop
Recommended (offline sync): Quit Antigravity Desktop first, then run:
agy-sync sync --direction cli-to-desktop --applyRe-open Antigravity Desktop to see your synced conversations.
While Antigravity Desktop is open (Live RPC):
agy-sync sync --direction cli-to-desktop --apply --live-rpcCopies conversation DBs/brain/annotations safely and registers summaries with the running
language_servervia RPC instead of writing directly to its open SQLite/proto cache.
4. Sync from Desktop to CLI
Quit any active agy CLI session, then run:
agy-sync sync --direction desktop-to-cli --apply
(If a CLI daemon is running and you explicitly want to proceed, pass --allow-live.)
5. Bidirectional sync & CLI ↔ Desktop ping-pong
agy-sync sync --direction both --apply
You can continue the same conversation back and forth across CLI and Desktop:
- Start in CLI (
A), sync to Desktop (A'). - Continue chatting in Desktop (
A'), then runagy-sync sync --direction both --apply—agy-syncfast-forwardsA' → Ain place ([back-sync]) without creating a third copy. - Continue chatting in CLI (
A), then runagy-sync sync --direction both --apply—agy-syncfast-forwardsA → A'in place. - If both sides were edited independently (or
state.jsonhas no watermark proving the origin is untouched),agy-syncreportsCONFLICTand refuses to overwrite unless--forceis explicitly passed.
Common Workflows
Sync specific sessions only (get root UUIDs from agy-sync plan):
agy-sync sync --direction cli-to-desktop -s <uuid-1> -s <uuid-2> --apply
Assign synced CLI sessions to a specific Desktop project (by project name or ID from agy-sync projects):
agy-sync sync --direction cli-to-desktop -p my-project --apply
Machine-readable JSON output (useful for scripts or auditing):
agy-sync plan --direction both --json
agy-sync status --json
Force re-syncing up-to-date or diverged mirrors:
agy-sync sync --direction cli-to-desktop --force --apply
Use custom directory paths (for testing or non-default setups):
agy-sync plan --cli-dir /path/to/antigravity-cli --app-dir /path/to/antigravity --config-dir /path/to/config
CLI Reference
| Command | Description | Writes to disk? |
|---|---|---|
agy-sync tui |
Launch the interactive Terminal UI (also default for bare agy-sync in a TTY) |
Only when confirmed (x → y) |
agy-sync status |
Show store paths, daemon status, session counts, and ledger summary | No |
agy-sync projects |
List discovered Desktop projects and workspace paths | No |
agy-sync plan |
Compute and display the sync plan | No |
agy-sync sync |
Plan or execute sync (defaults to --dry-run) |
Only with --apply |
| Flag | Applies to | Description |
|---|---|---|
-d, --direction {cli-to-desktop,desktop-to-cli,both} |
tui, plan, sync |
Sync direction (default: both) |
-s, --session <uuid> |
plan, sync |
Filter to specific root conversation UUID(s); repeatable |
-p, --project <id-or-name> |
tui, plan, sync |
Override target Desktop project for cli-to-desktop |
-n, --dry-run |
sync |
Plan only with zero writes (default when --apply is omitted) |
--apply |
sync |
Execute the planned writes |
--force |
plan, sync |
Re-sync up-to-date mirrors or overwrite diverged mirrors |
--live-rpc |
sync |
Sync summaries to a running Desktop daemon via live RPC |
--allow-live |
sync |
Allow writing to the CLI store when a CLI daemon is active |
--no-backup |
sync |
Skip pre-write snapshots of target index files |
--json |
all | Emit machine-readable JSON output |
--cli-dir, --app-dir (--desktop-dir), --config-dir, --state-file |
all | Override default paths under ~/.gemini/ |
Data Safety, Backups & Recovery
- Ledger location:
~/.gemini/agy-sync/state.json(tracks synced root/subagent pairs and timestamps for idempotency and conflict detection). - Pre-write backups: Before writes,
agy-syncsnapshots the target store'sconversation_summaries.db,agyhub_summaries_proto.pb/jetbox_summaries_proto.pb, and any existingconversations/<dst_cid>.dbbeing updated into~/.gemini/agy-sync/backups/<YYYYMMDD_HHMMSS>/<store>/. - Restoring from backup: Quit the target Antigravity app, copy the backed-up
conversation_summaries.db,*.pb, and anyconversations/<cid>.dbback into~/.gemini/antigravity/(or~/.gemini/antigravity-cli/). - Technical specification: See docs/DESIGN.md for the complete storage schema, protobuf wire layout, UUID mapping rules, and daemon safety design.
Troubleshooting
- "Target daemon is running" error when passing
--apply: Quit Antigravity Desktop (oragyCLI) before running offline sync, or pass--live-rpcfor Desktop /--allow-livefor CLI. - Legacy
.pbconversations are skipped: Older Antigravity versions stored trajectories as.pbfiles instead of SQLite.dbfiles.agy-syncintentionally skips legacy.pbfiles rather than risking corruption. - "conflict" action in
agy-sync plan: Both the original conversation and its synced mirror have been modified since the last sync. Inspect both sides and pass--forceif you want the source to overwrite the mirror. - Uninstall:
uv tool uninstall agy-sync # or: pipx uninstall agy-sync
Development
git clone https://github.com/hduc-le/agy-sync.git
cd agy-sync
uv sync
uv run ruff check .
uv run pyright
uv run pytest -v
See CONTRIBUTING.md before submitting pull requests.
License
Explore related projects
Loading…