engram-bridge
Route selected Engram projects to a second store and cloud, from a single local Engram store.
Unofficial. engram-bridge is a community companion tool. It is not affiliated with, endorsed by, or supported by the Engram maintainers.
New here? Read the usage guide: install, add a target, route projects, schedule, the terminal panel and troubleshooting, step by step.
Why
An Engram store replicates to one cloud. If you keep work memories in a company cloud and personal projects in your own (or one cloud per client), a single store cannot split them. Per-project routing was requested upstream in Gentleman-Programming/engram#392 and closed as wontfix, so this tool does the routing outside Engram, using only Engram's public CLI.
How it works
flowchart LR
A[Source store<br/>~/.engram] -- "engram export --project" --> B[(export file<br/>private temp dir)]
B -- "engram import" --> C[Target store<br/>~/.engram-personal]
C -- "engram sync --cloud" --> D[(Target cloud<br/>engram.example.com)]
Per listed project, engram-bridge run does:
- Refuse if the source store's own cloud has the project enrolled.
exportthe project from the source store (the source is only ever read).importit into the target store, with that target's token only.sync --cloud --projectfrom the target store to the target cloud.- If the import updated existing records, run
cloud upgrade remirror(see Limitations); retried on later runs until it succeeds.
A project belongs to at most one target. Everything is driven by one JSON config file, ${XDG_CONFIG_HOME:-~/.config}/engram-bridge/config.json (override with --config PATH or $ENGRAM_BRIDGE_CONFIG; reference in docs/guide.md).
In short, think of notebooks: your main store is one notebook that Engram can copy to one cloud (engram cloud enroll). The bridge reads that notebook and copies the projects you list into a second notebook per target, which it copies to that target's cloud. A project is routed to one place only: the main cloud or one target (a routing rule: copies already pushed are not recalled, and remove leaves data and enrollment in place). The guide explains it with a picture.
Quick start
Step-by-step version with expected output, scheduling and troubleshooting: usage guide.
Requirements: Python 3.11+, the engram CLI 3.x from 3.7 (no prereleases) on PATH, a reachable Engram cloud server for each target.
# 1. install
uv tool install engram-bridge
# or: pipx install engram-bridge
# latest from main: uv tool install git+https://github.com/manelrv/engram-bridge
# 2. guided setup (interactive terminal)
engram-bridge setup
setup asks for each value with its default in brackets (press Enter to accept): the main store ($ENGRAM_DATA_DIR or ~/.engram, which must already hold an Engram store), the target name, its server URL and store directory (~/.engram-NAME), then the token (read hidden and stored in the macOS Keychain or with secret-tool, never on a command line). It then runs doctor, offers to route the current directory's project and to install the schedule, and prints what to run next. Ctrl-C at any prompt aborts and tells you what was already done. engram-bridge tui with no config runs setup first. setup needs a terminal; without one (or with --json) it exits 2.
Manual, scriptable alternative
setup only calls the commands below, so scripts and CI can run them directly:
# 2. create the config; the source is the store your agents write to
# (--source defaults to $ENGRAM_DATA_DIR, else ~/.engram, and the command prints which;
# the directory must be an initialized Engram store, i.e. hold engram.db; an empty --source= is an error)
engram-bridge init --source ~/.engram
# 3. store the target's token (below), then register the target
# (--store defaults to ~/.engram-NAME)
target add also points the target store at its server (engram cloud config --server URL, run with a sanitized environment and no token) and checks the result; pass --no-configure-store to skip that. Engram sends bearer tokens only over https://, so a target with a token needs an https:// server (plain http:// is accepted only for token-less servers on localhost or 127.0.0.1).
Store the target's token with one backend and register the target with the matching flag (--token-keychain-account ACCOUNT sets the Keychain account; default $USER):
# macOS Keychain (prompts for the token; -w without a value reads it interactively)
security add-generic-password -a "$USER" -s engram-bridge/personal -w
engram-bridge target add personal --store ~/.engram-personal \
--server https://engram.example.com --token-keychain engram-bridge/personal
# Linux Secret Service (prompts for the token)
secret-tool store --label="engram-bridge personal" service engram-bridge target personal
engram-bridge target add personal --store ~/.engram-personal \
--server https://engram.example.com --token-secret-tool service=engram-bridge target=personal
# Or let engram-bridge store it: the token is read from stdin (never from argv) and written with
# `security -i` (macOS, add-generic-password -U) or `secret-tool store` (Linux), then read back to verify
printf '%s' "$TOKEN" | engram-bridge target add personal --store ~/.engram-personal \
--server https://engram.example.com --token-keychain engram-bridge/personal --token-stdin
# macOS only accepts tokens, services and accounts made of letters, digits and . _ ~ + / = : @ - (not starting
# with -) this way; anything else is refused. secret-tool accepts any printable token.
# --token-stdin refuses an interactive terminal (a typed token would be echoed): pipe it, or use `engram-bridge tui`.
# It also refuses (exit 3) to overwrite an existing item that holds a different token; rotate by hand with
# `security add-generic-password -U …` / `secret-tool store …`, then run target add without --token-stdin.
# Any OS: environment variable (not available to scheduled runs: doctor warns about it)
engram-bridge target add personal --store ~/.engram-personal \
--server https://engram.example.com --token-env MY_TARGET_TOKEN
Omit the token flag for a server without auth. Then:
engram-bridge add my-side-project --target personal # enroll + route a project
engram-bridge run # bridge now (--dry-run to preview)
engram-bridge doctor # check engram, servers, tokens, schedule
engram-bridge install-schedule # launchd (macOS) / systemd user timer (Linux), every 30 min
Projects in no cloud: status (text and --json) and the dashboard warn about main-store projects that are not enrolled in Engram's own cloud, not routed to any target and not declared local on purpose (! 2 projects in no cloud: foo, bar, with the add and keep-local commands to fix it). engram-bridge keep-local PROJECT... declares projects that stay local (--remove undoes it; the Gentle Shell package shows the same warning when a session starts). It never routes anything by itself.
Other commands: list, keep-local PROJECT... [--remove], status, remove PROJECT, project [--cwd DIR], log [--lines N] (redacted tail of the scheduled-run log), source (read-only list of the main store's projects and which are enrolled in Engram's own cloud: managed by Engram with engram cloud enroll, not by engram-bridge), target remove NAME, uninstall-schedule, tui, version. Every command accepts --config PATH, and every command except setup and tui accepts --json (setup and tui are for humans: with --json, or without a TTY, they are a usage error; --config PATH works). Full reference: docs/CONTRACT.md.
Terminal panel
engram-bridge tui opens an interactive panel (Python's standard curses; macOS and Linux, no extra dependency). It needs a real terminal: without a TTY, or with --json, it is a usage error (exit 2). It lists targets, their projects and each project's last run (ok / FAILED, time, new/updated/skipped, pending remirror, error), and every action goes through the same commands and guards as the command line:
| Key | Action |
|---|---|
up / down (k / j) |
move the cursor |
s / S |
sync the selected project (or target) / sync everything |
a |
add the current directory's project (as project resolves it) to the selected target |
A |
add a typed project name to the selected target (validated like add) |
r |
remove the selected project from its target (asks to confirm; no data is deleted) |
m |
move the selected project to another target (remove + add; if the add is refused the config is put back, best effort) |
t |
add a target: name, store, server, Keychain service and account (macOS) or secret-tool attributes (Linux) and a masked token, stored with --token-stdin |
c |
Main cloud: a read-only panel listing every enrolled project of the main store (◇), unknown ones (?) and the local-only count (j/k scroll, Esc/q close); uses the data already loaded, never calls Engram |
d |
doctor checks |
l |
tail of the scheduled-run log (launchd log file on macOS, user journal on Linux) |
g |
refresh (also re-reads the Main cloud section) |
q / Esc |
quit (or go back / cancel a prompt) |
The home screen is an Engram-style dashboard, top to bottom: a framed banner (⇄ BRIDGE ONLINE, or ⇄ BRIDGE DEGRADED in red when a project's last run failed or the config cannot be read, which shows SYNC: ERROR; SYNC: OK n/m, SYNC: n FAILED, n PENDING; BRIDGE in block letters; a tagline), a stats card (targets, projects routed, and, when not zero, ok, failed, pending remirror), the Targets list (targets and their projects with the last run: ✓ ok / ✗ failed / never run, the failure cause, the time at the right edge, a yellow ! remirror pending) and the Actions menu (each item shows its letter key). It comes from the config and the last-run data, never from running doctor.
Tab (or Shift-Tab) moves the focus between Targets and Actions; the focused list has the lavender ▸, the other one a dimmed ▸. Enter on a target or project moves the focus to Actions with that row as the context (shown next to the Actions heading); Enter on an action runs exactly what its letter key runs. Every letter key in the table keeps working whichever list has the focus. The help bar shows j/k: navigate • tab: focus • enter: select • s: sync • S: sync all • q: quit, wrapping on narrow terminals.
The look is the Rosé Pine palette of the Engram and Gentle AI terminal tools. On a 256-colour terminal the screen is painted with the palette's dark background (panels one shade lighter): exact colours when the terminal can redefine them, the nearest xterm-256 colours otherwise. With 8 colours, or none, nothing is painted (your terminal's own background; bold/dim/reverse only without colour). With a non-UTF-8 locale it draws ASCII (>, +, x, |, -, a plain BRIDGE banner).
The banner and the stats card need at least 39 rows and 77 columns (the terminal's own margin included). On a smaller terminal (80x24 included) the header is one line (⇄ engram-bridge SYNC: OK n/m and the config path) and the stats sit inline on the Targets heading, so the targets list and the menu stay visible; the Targets list scrolls (n/m shows the cursor position) and the menu is hidden only when there is no room left for it.
Projects you route are never picked from a list: you add the current directory's project or type a name. Under the Targets and the Actions menu, a dimmed, read-only Main cloud section previews up to 5 of the main store's projects that are enrolled in Engram's own cloud (◇, # in ASCII; ? when unknown), then …and n more • c: view all, and how many are local-only; c opens the full list. They are managed by Engram (engram cloud enroll), not by engram-bridge; the section is read with engram-bridge source at startup and on g, and is never selectable. On small terminals it is the one line Main cloud (Engram): n enrolled • m local-only • c: view. When some projects are in no cloud, a yellow line ! n in no cloud: names • keep local: engram-bridge keep-local name closes the section (on small terminals it is a second line under the one-line summary; long names are shortened with … before the keep-local hint is clipped).
Gentle Shell
A Gentle Shell (Pi) package adds /engram-route (list, add, remove, sync, an interactive /engram-route tui panel, plus a warning at session start when a sync failed). It only runs the engram-bridge CLI; no model calls, no tokens.
gentle-shell install git:github.com/manelrv/engram-bridge
Details: gentle-shell/README.md.
Safety guards
These invariants are enforced in code and covered by tests (see SECURITY.md):
- Every
engramcall gets a sanitized environment:- every inherited
ENGRAM_*variable and every configured token variable is removed; ENGRAM_NO_UPDATE_CHECK=1is always set;ENGRAM_DATA_DIRis set explicitly on every call that uses a store (the storelessengram versioncheck uses none).
- every inherited
- When the config is invalid,
doctorstill hides the token variable names it can read from the file. - Keychain /
secret-toollookups run withoutENGRAM_*variables or other targets' token variables. - A target's token reaches only calls on that target's store. Never the source, never another target.
- The source store is used only for
export, enrollment status,engram projects list(the read-onlysourceview, also read bystatusfor the "in no cloud" warning) and project resolution (plusengram importwhen a target has pull-back on).keep-localmakes noengramcall. - Source and target stores must be different directories. Both canonical paths and existing directory identities are checked.
- Immediately before every write (import, sync, remirror, enroll), the target store must report exactly one
Server:line equal to the configured server. This check runs without the token. A refused target stops before its next write; other targets still run. - Exit code
3means a safety check stopped that project before its next write; earlier steps of the run may already have happened. - A project already enrolled in the source store's cloud is refused; if that cannot be determined, it is refused too (fail closed).
- Tokens are redacted from every error, diagnostic and state entry before truncation.
- Project names are validated against
[A-Za-z0-9][A-Za-z0-9._-]*(full match), including hand-edited configs. - A pending remirror is retried on each run until it succeeds.
- The config and state files are written atomically with mode 0600 (directory 0700). Scheduled unit files never contain tokens.
Projects without memories yet
A project you route before Engram has saved anything for it is waiting, not failed: add notes it (NAME has no memories in the main store yet; engram-bridge will copy it once it has some), run reports waiting: no memories yet with exit code 0 (JSON: "waiting": true), and the terminal panel and /engram-route show it as waiting (SYNC: OK n/m k WAITING). Only Engram's exact answer engram: unknown project: NAME counts; any other export error is still a failure.
Pull-back (opt-in, writes the main store)
Pull-back writes your main store. It is off by default and opt-in per target (target pull NAME on, or target add --pull). When on, after the normal push run downloads the project's cloud chunks into the TARGET store (sync --cloud --import --project P; plain sync --cloud only pushes, it does not download), exports it from there and imports it into the MAIN store with Engram's own engram import: idempotent by sync id, last writer wins by updated_at, no merge. Turn it on with engram-bridge target pull NAME on (off: target pull NAME off; target add NAME ... --pull for a new target). list marks the target [pull], run appends , pulled N new, M upd, K already present, and status appends [pulled N new, M upd, K already present].
Guards: only projects routed to that target are pulled, and only from their owner target; a project enrolled in the main store's cloud is refused first (exit 3) and checked again right before the import, so it can never be imported through the bridge; the main store is written only through engram import (sanitized environment, ENGRAM_DATA_DIR = main store, no token); the main store is never created (a store without engram.db is refused by the enrollment check exactly as without pull-back: exit 3, nothing imported); a pull failure marks that project failed (error starts with pull: ) and the next run retries; the bridge never deletes anything and rolls nothing back; a pull reported as failed after the import already ran (for example an unparseable import summary) may already have imported memories, which is safe because Engram's import is idempotent. A project that is still waiting (not yet in the main store) still syncs from the cloud and is pulled, so a new machine gets it and the waiting state resolves itself.
Limitations
- One direction by default. Main store → target cloud. Unless you turn on pull-back for a target (
engram-bridge target pull NAME on, see Pull-back), the bridge never writes your main store, so memories another machine pushed to the target cloud are not brought back to this machine's agents. See the same project on several machines. - Deletes are not propagated. Hard-deleted observations and deleted prompts are not removed from the target.
removenever deletes data either. - Revision history is not propagated. Only current records travel through export/import.
- Updates cost a full re-push. When an import updates existing records,
remirrorre-pushes a full project chunk to the target cloud. - Text parsing. Some fields exist only in Engram's human-readable output (
Server:,Project enrollment:,N imported, M updated, K skipped). The supported Engram range is>=3.7,<4, andrun,addandtarget addrefuse to write with any other version; unknown or ambiguous output makes the tool fail closed rather than guess. Machine-readable output has been proposed upstream (engram#392). - The target server must run Engram 3.7+ as well;
doctorchecks that it answers as Engram Cloud (target.server_health) and accepts your token (target.token).
Compatibility
| Component | Supported |
|---|---|
| OS | macOS (launchd, Keychain), Linux (systemd user timer, secret-tool). Windows is not supported natively (it needs curses, launchd/systemd and the Keychain / Secret Service); use WSL (Ubuntu), where the Linux path works, see the guide. |
| Python | 3.11, 3.12, 3.13 (standard library only) |
| Engram CLI and server | 3.x from 3.7 (>=3.7,<4), no prereleases |
| Gentle Shell package | Node >= 22 for its tests only |
Contributing and license
See CONTRIBUTING.md and SECURITY.md. Changes: CHANGELOG.md. Licensed under the MIT License.
Metadata
Release files for engram-bridge 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| engram_bridge-0.2.3.tar.gz | 123.5 kB | With provenance | Details for engram_bridge-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| engram_bridge-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for engram_bridge-0.2.3-py3-none-any.whl |
Total release size: 181.7 kB
Release files / engram_bridge-0.2.3.tar.gz
| Download URL | engram_bridge-0.2.3.tar.gz |
|---|---|
| Size | 123.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68a46e38cc671a1411f2cfceca0929204278e4805ddaf08f37279b19537d250f
|
|
BLAKE2b-256 checksum How to use checksums |
ee20480f5a5675c64b87420965c617b0f7acd49ed12bbc436c774c2610459371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logRelease files / engram_bridge-0.2.3-py3-none-any.whl
| Download URL | engram_bridge-0.2.3-py3-none-any.whl |
|---|---|
| Size | 58.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40ee7ac33c870a5acec7c8b433cbebff5b1787f0f0d873ec597984b7829acf16
|
|
BLAKE2b-256 checksum How to use checksums |
ddd5da026c3a03142cb11abd90c04153ee2bfa537630b04463d62a5413b8b523
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logSecurity for engram-bridge 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for engram_bridge-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.