Skip to content

shadowline-trx/brainsync-universal

Repository files navigation

BrainSync Universal

Local-first AI memory sync across VS Code, Kiro, Windsurf, Cursor, Cline, Gemini CLI, Antigravity, and any VS Code-compatible IDE.

Switch IDEs without losing project context. BrainSync keeps a single, append-only memory log per project and writes a fresh "agent context" file to every rule path each IDE expects (AGENTS.md, .windsurfrules, .cursor/rules/brainsync.mdc, .kiro/steering/brainsync.md, CLAUDE.md, .clinerules, .gemini/GEMINI.md, ...). When an agent in any IDE adds rules, lessons, or decisions to its rule file, BrainSync rescues those edits back into memory and propagates them to every other IDE on the next sync.

No cloud, no account, no telemetry. Everything is files on your disk.


Why

You probably use more than one AI IDE. Maybe Windsurf for one project, Cursor for another, Kiro for a third, plus Antigravity Brain for marketing work. Each one keeps its own private chat history and rule files. The moment you switch, the new agent has zero context.

BrainSync solves this by:

  1. Keeping every project's memory in one canonical append-only log: .brainsync/memory.jsonl.
  2. Mirroring that log to a shared per-user vault: ~/.brainsync-vault/projects/<project-key>/.
  3. Writing the same generated context to every IDE's rule format on every change.
  4. Reading back what each IDE's agent wrote, so memory grows over time instead of being overwritten.
  5. For Antigravity Brain artifacts and Windsurf Cascade session metadata, importing those automatically.

The result: open the same project folder in any supported IDE, and the new agent inherits the project's full handoff brief immediately.


Supported IDEs and rule paths

IDE Files BrainSync writes
Generic / multi-IDE AGENTS.md
Claude Code CLAUDE.md
Gemini CLI GEMINI.md, .gemini/GEMINI.md
Windsurf .windsurfrules, .windsurf/rules/brainsync.md
Cursor .cursorrules, .cursor/active-context.md, .cursor/rules/brainsync.mdc
Cline .clinerules
Antigravity Brain .gemini/antigravity/brain/brainsync.md
Kiro .kiro/steering/brainsync.md
Agent Memory .agent-mem/last-session.md

Each path can be customized via the brainsyncUniversal.exportTargets setting.


Install

  1. Grab the latest VSIX from Releases (or build it yourself; see Build).

  2. In each IDE you use:

    # VS Code
    code --install-extension brainsync-universal-X.Y.Z.vsix --force
    
    # Kiro
    kiro --install-extension brainsync-universal-X.Y.Z.vsix --force
    
    # Windsurf
    windsurf --install-extension brainsync-universal-X.Y.Z.vsix --force
    
    # Cursor
    cursor --install-extension brainsync-universal-X.Y.Z.vsix --force
  3. Open the same workspace folder in each IDE. BrainSync activates automatically and writes a status item to the bottom-left bar.


Quick start

After install, in any IDE:

  1. Initial pull-in: open the command palette and run BrainSync Universal: Import Existing Agent Files. BrainSync absorbs whatever rules, lessons, and notes are already in AGENTS.md, .windsurfrules, .cursor/rules/*.mdc, etc.

  2. Capture the important stuff as it happens:

    • Select text in the editor → BrainSync Universal: Capture Selection as Memory
    • Copy a Cascade or chat reply → BrainSync Universal: Capture Clipboard as Conversation
    • Type a free-form note → BrainSync Universal: Add Conversation Note
  3. Switch IDEs. The other IDE's BrainSync auto-syncs the same memory and re-renders the rule files for that IDE's format.

For Windsurf specifically, BrainSync also reads Cascade session metadata (titles, status, timestamps) directly from state.vscdb, so other IDEs can at least see "you had a session called X about this workspace last touched Y" even though Cascade chat content is encrypted by Windsurf.


How it works

Storage

project/
├─ .brainsync/
│  ├─ memory.jsonl          # canonical append-only log (single source of truth)
│  ├─ generated-context.md  # last rendered context preview
│  ├─ index.json            # quick stats
│  ├─ sync-state.json       # mtime tracking for incremental sync
│  ├─ shadows/              # byte-exact copies of files we last wrote
│  └─ backups/              # timestamped backups before each overwrite
├─ AGENTS.md                # generated
├─ CLAUDE.md                # generated
├─ GEMINI.md                # generated
├─ .windsurfrules           # generated
├─ .cursor/rules/brainsync.mdc  # generated
├─ .kiro/steering/brainsync.md  # generated
└─ ...                      # one file per IDE rule format

~/.brainsync-vault/projects/<project-key>/
└─ memory.jsonl             # mirrored copy, lets other IDEs find the same project

The project key is derived from the git remote URL when present, otherwise from the workspace path. This lets the same repo opened in different IDEs resolve to the same vault.

Sync engine (v0.2.1+)

flowchart TB
    subgraph Trigger
        FW[File Watcher] --> AL[Anti-Loop Gate<br/>1.5s write cooldown] --> CD[Adaptive Debounce<br/>800ms → 4s → 8s]
    end

    subgraph Import
        MT[Mtime Check<br/>skip unchanged] -->|changed| SD[Shadow Diff<br/>current vs last-written]
        MT -->|changed| NI[Normal Import<br/>non-generated files]
        SD -->|delta| MEM
        NI --> MEM
    end

    subgraph Export
        RS[Rescue Phase<br/>diff targets vs shadows] --> MEM
        MEM --> BC[Build Context] --> NO[No-op Check<br/>hash unchanged?]
        NO -->|changed| WR[Write Targets<br/>+ update Shadows]
        NO -->|same| SKIP[Skip Export]
    end

    MEM[(memory.jsonl)]
    SH[(.brainsync/shadows/)]
    SS[(.brainsync/sync-state.json)]

    CD --> Import --> Export
    WR --> SH
    WR --> SS
Loading

Six things make it cheap and loop-safe:

  • Shadow copies — every file BrainSync writes gets a byte-exact copy in .brainsync/shadows/. On the next sync, the shadow is diffed against the current file to find precisely what an IDE agent added in between.
  • Mtime tracking — files unchanged since the last sync are skipped entirely.
  • Anti-loop cooldown — when BrainSync writes a target, file watchers ignore changes within 1.5s so we don't trigger ourselves.
  • Adaptive debounce — starts at 800ms, backs off to 4s after 3 consecutive no-ops, then 8s. Resets instantly on real change.
  • No-op skip — if the rendered context hash matches the last export and no entries were rescued, the entire export is skipped.
  • Watcher separation — import-only files (e.g., .brainsync/agent-rules.md) trigger immediate sync; export targets are watched with the cooldown gate.

IDE conversation imports

Source What we read What we cannot read
Antigravity Brain ~/.gemini/antigravity/brain/** overview + artifact files (plaintext) n/a — fully accessible
Windsurf Cascade NDJSON ~/AppData/Roaming/Windsurf/User/acp-events/*.ndjson (plaintext summaries when present) full chat transcripts
Windsurf session metadata state.vscdb → windsurf.acp.metadataCache via SQLite (titles, status, timestamps, cwd) actual messages
Windsurf Cascade .pb files only file mtime / id content (encrypted client-side)

For encrypted chat content, the workflow is: copy from the IDE's chat panel → run BrainSync Universal: Capture Clipboard as Conversation. That's two seconds and the next agent in any IDE has the full transcript.


Commands

Command What it does
BrainSync Universal: Open Dashboard Sidebar panel with stats, search, capture, recent entries
BrainSync Universal: Scan Workspace Pull memory from any markdown/text file in the workspace
BrainSync Universal: Capture Selection as Memory Save the current editor selection as an entry
BrainSync Universal: Add Conversation Note Prompt for a title + body, save as conversation
BrainSync Universal: Capture Clipboard as Conversation One-shot import for Cascade replies, ChatGPT outputs, etc.
BrainSync Universal: Search Memory Quick-pick search across all entries with file paths preserved
BrainSync Universal: Import Existing Agent Files Re-import all known rule files
BrainSync Universal: Export Agent Context Force a re-render of every IDE rule file
BrainSync Universal: Import Latest Windsurf Cascade Session Force-import the most recent Windsurf NDJSON session (manual, for project mismatches)
BrainSync Universal: Open Generated Context Open .brainsync/generated-context.md
BrainSync Universal: Toggle Auto Sync Disable/enable the watcher

Configuration

All settings live under brainsyncUniversal.*. Useful ones:

Setting Default Purpose
autoSync true Toggle watch + auto re-export
vaultPath "" Custom shared vault folder. Empty = ~/.brainsync-vault
maxContextEntries 60 Top-N entries included in the rendered context (priority + date sorted)
scanMaxFiles 250 Cap on workspace scans
exportTargets see Supported IDEs Files BrainSync writes
importFiles (mirror of exportTargets + globs) Files BrainSync ingests
importIdeConversationStores true Whether to read Antigravity / Windsurf chat stores
antigravityBrainPath ~/.gemini/antigravity/brain Antigravity Brain root
windsurfAcpEventsPath ~/AppData/Roaming/Windsurf/User/acp-events Windsurf Cascade NDJSON folder
windsurfStateDbPath ~/AppData/Roaming/Windsurf/User/globalStorage/state.vscdb Windsurf SQLite for session metadata

What BrainSync is not

  • Not a chat history grabber. Most IDEs encrypt chat client-side. We read what they expose to disk in plaintext (rule files, summaries, metadata) and provide one-keystroke clipboard capture for everything else.
  • Not a cloud product. Memory stays in .brainsync/ and the per-user vault. No outbound network.
  • Not a vector store. Search is keyword-based across titles, content, sources, tags, and project paths. Good enough for handoff context; for semantic search use a real vector DB.
  • Not opinionated about agents. BrainSync writes the same context to every rule file. What each agent does with it depends on that agent.

Build

git clone https://github.com/shadowline-trx/brainsync-universal.git
cd brainsync-universal
npm install
npx @vscode/vsce package --no-dependencies --out dist

Output: dist/brainsync-universal-X.Y.Z.vsix.

@vscode/vsce is run via npx. Vendored sql.js files in vendor/sql.js/ are bundled — they're needed to read Windsurf session metadata without a native dependency.


Privacy

  • Memory log: <workspace>/.brainsync/memory.jsonl
  • Mirror: ~/.brainsync-vault/projects/<project-key>/memory.jsonl
  • Backups before each overwrite: <workspace>/.brainsync/backups/
  • Shadows: <workspace>/.brainsync/shadows/
  • No network calls. The vault is a local folder, not a cloud account.

If you commit the workspace, decide whether to commit .brainsync/. The included .gitignore excludes the runtime memory log and shadows by default and keeps only source code. Generated rule files (AGENTS.md, .windsurfrules, etc.) are also excluded by default since they're regenerated from memory.


For Kiro users who want a pre-built "fully autonomous" config, see docs/example-kiro-settings.json — copy it to %APPDATA%\Kiro\User\settings.json (Windows) or ~/.config/Kiro/User/settings.json (Linux/macOS) and reload. This trusts every workspace and skips approval prompts; only enable on machines where every project is yours.


License

MIT — see LICENSE.


Contributing

Issues and PRs welcome. Please:

  • Match existing code style (single file, no transpiler, ES2022, no any in jsdoc).
  • Keep dependencies minimal. The vendored sql.js is the only runtime dependency.
  • Don't break the file-only, local-first model. No outbound network.

For deeper context, see docs/ARCHITECTURE.md. For releasing to marketplaces, see docs/PUBLISHING.md. For workflow rules, see CONTRIBUTING.md.

About

Local-first AI memory sync across VS Code, Kiro, Windsurf, Cursor, Cline, Antigravity, and Gemini CLI. No cloud, no telemetry. Files only.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages