Metadata-Version: 2.4
Name: agent-memory-bridge
Version: 0.39.1
Summary: Governed project memory for AI coding agents across sessions and tools
License-Expression: MIT
Project-URL: Homepage, https://github.com/zzhang82/Agent-Memory-Bridge
Project-URL: Repository, https://github.com/zzhang82/Agent-Memory-Bridge
Project-URL: Issues, https://github.com/zzhang82/Agent-Memory-Bridge/issues
Project-URL: Documentation, https://github.com/zzhang82/Agent-Memory-Bridge#readme
Keywords: mcp,memory,agents,project-memory,governance,sqlite,fts,local-first,stdio,streamable-http
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<3,>=2.0.0
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == "dev"
Requires-Dist: hypothesis<7,>=6.130; extra == "dev"
Requires-Dist: mypy<2,>=1.15; extra == "dev"
Requires-Dist: pip-audit<3,>=2.9; extra == "dev"
Requires-Dist: PyYAML<7,>=6.0; extra == "dev"
Requires-Dist: pytest<10,>=9.0.3; extra == "dev"
Requires-Dist: pytest-cov<8,>=6; extra == "dev"
Requires-Dist: ruff<1,>=0.12; extra == "dev"
Requires-Dist: setuptools>=83; extra == "dev"
Requires-Dist: twine<7,>=6; extra == "dev"
Dynamic: license-file

<p align="center">
  <img src="assets/amb-hero.png" alt="Agent Memory Bridge — governed project memory across sessions and tools" width="100%" />
</p>

<p align="center">
  <a href="assets/readme-loop-v1.2-1280x720.mp4"><img src="assets/readme-loop-v1.2.gif" alt="Scripted UI of a local stdio loop: one session stores an example decision, and a fresh process on the same AMB home recalls that same record from a real local AMB v0.38.4 run." width="880" /></a>
</p>

<h1 align="center">Agent Memory Bridge</h1>

<p align="center"><strong>Teach one decision and its reason. The next session can recall that reason when it recalls at the start.</strong></p>

<p align="center">
  AMB keeps a confirmed project decision in a local store. A later session gets it back by recalling, not by rereading the old chat.
</p>

<p align="center"><a href="README.zh-CN.md">简体中文</a></p>

<p align="center">
  <a href="https://pypi.org/project/agent-memory-bridge/"><img src="https://img.shields.io/pypi/v/agent-memory-bridge?logo=pypi&logoColor=white" alt="PyPI" /></a>
  <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP_Server-Enabled-4A90E2?logo=protocolsdotio&logoColor=white" alt="MCP Server" /></a>
  <a href="https://github.com/zzhang82/Agent-Memory-Bridge/actions/workflows/ci.yml"><img src="https://github.com/zzhang82/Agent-Memory-Bridge/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
  <a href="https://github.com/zzhang82/Agent-Memory-Bridge/releases"><img src="https://img.shields.io/github/v/release/zzhang82/Agent-Memory-Bridge?logo=github&color=2ea44f" alt="GitHub Release" /></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-2ea44f.svg" alt="MIT License" /></a>
  <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.11%2B-3776AB.svg" alt="Python 3.11+" /></a>
</p>

## The loop

One process stores a decision. A second process, on the same AMB home, recalls the claim and the reason. The recording is that local stdio proof. It is not a filmed coding-agent session, and it is not an adoption measurement.

The source is [examples/demo/first-win-demo.cast](examples/demo/first-win-demo.cast). The block below is an abridged transcript of that cast. Regenerating it runs the two processes, then writes generated playback: the header time and the line delays are fixed, not a measurement of the run. Command: `python ./scripts/build_first_win_cast.py`. Rendering a GIF needs `agg`; this repository does not include that GIF.

```text
# Session A: store one explicit decision
namespace: project:checkout-app
claim: Merge pull requests only after CI is green on the target branch.
reason: Broken main blocked two releases this month.
stored: true

# Session B: a second stdio process, same home, recall at start
query: What is required before we merge a pull request?
claim: Merge pull requests only after CI is green on the target branch.
reason: Broken main blocked two releases this month.
same_record: true
fresh_process: true
```

## Recall at the start

Connecting the server is not enough. The next session has to recall on purpose. This page does not claim that connecting MCP, or leaving a skill where it can be found, makes that happen by itself. There is no automatic learning.

Put this rule where the next session will actually follow it:

```text
Before changing code, recall this project's Agent Memory Bridge decisions and their reasons.
Use the namespace from `project resolve`. Call the public `recall` tool.
Store a decision only after it is confirmed. Do not treat chat history as already stored.
```

## Install, then bind the project

AMB requires **Python 3.11+** and Git.

Current package/source version: `0.39.1`.

```bash
python3 -m venv .amb-venv
.amb-venv/bin/python -m pip install agent-memory-bridge==0.39.1
.amb-venv/bin/python -m agent_mem_bridge project init . --yes
.amb-venv/bin/python -m agent_mem_bridge doctor
```

In later commands, `<venv-python>` means `.amb-venv/bin/python` on Linux and macOS. `project init` detects the Git repository and proposes a namespace such as `project:my-app`; it accepts `--yes` for non-interactive runs and `--dry-run` to preview without writing. It does not learn decisions from the tree. After that, `project resolve .` returns the namespace.

Run `<venv-python> -m agent_mem_bridge` with one persistent `AGENT_MEMORY_BRIDGE_HOME`. Configure a client with `connect <client> --yes` (and `triggers install <client> --yes`), or write the command shape by hand from [Integrations](docs/INTEGRATIONS.md). Connection is real when the client lists `store` and `recall`.

Store one confirmed decision with `store`:

```text
record_type: decision
claim: Merge pull requests only after CI is green on the target branch.
reason: Broken main blocked two releases this month.
```

Free-form `kind="memory"` notes still recall, while `explore` and `inspect` list records that declare `record_type: decision` or `record_type: constraint`. In the next session, use the startup rule above and ask for that decision.

## What you can do with AMB

1. **Decisions and Rules**: Teach one confirmed project decision and its reason so the next session recalls *why* the code is written that way instead of guessing from chat history.
2. **Replacing Outdated Decisions**: When a decision changes, replace the older record cleanly so outdated rules stop surfacing by default while remaining in change history.
3. **Agent Handoffs and Claim Timeouts**: Post a short-lived handoff item that one worker claims with a timeout so parallel agents do not step on the same task.
4. **Tracked Work Runs and Proof Receipts**: Record multi-step run progress, verified outcomes, and tamper-evident receipts showing which memories surfaced.
5. **Connected Clients and Trigger Reminders**: Configure Claude Code, Cursor, Codex, Cline, and VS Code with a three-tier connection check (`config_valid`, `server_spawn_verified`, and `host_cli_verified` / `host_reload_required`), and install per-client reminders for the six workflow trigger moments.

Reading the Python source or raw MCP JSON? See the [Plain-Words to Code Glossary](docs/GLOSSARY.md) for the exact code and wire names (`namespace`, `supersedes`, `signal`, `lease_seconds`, `episode`, `attestation`).

<details>
<summary>Clients, triggers, an existing home, and optional review</summary>

Connect a supported client in one command and run the three-tier connection check:

```bash
<venv-python> -m agent_mem_bridge connect claude-code --yes
<venv-python> -m agent_mem_bridge connect cursor --yes
<venv-python> -m agent_mem_bridge connect codex --yes
<venv-python> -m agent_mem_bridge connect cline --config-path ~/.cline/data/settings/cline_mcp_settings.json --yes
<venv-python> -m agent_mem_bridge connect vscode --yes
<venv-python> -m agent_mem_bridge connect cursor --check
```

`connect` writes `.mcp.json` (Claude Code project scope, or VS Code Copilot project format), `.cursor/mcp.json`, `.codex/config.toml`, `.vscode/mcp.json`, or Cline settings (`cline_mcp_settings.json`). Point a client at a remote HTTP authority with `connect <client> --url <url> --token-file <path> --scope user`. Project-scope token writes require `--allow-project-token`, and that config file must stay gitignored and must not be committed.

Install per-client trigger reminders and inspect the honest 6×5 client support matrix (`native_hook`, `deferred_hook`, `trust_gated_hook`, `instruction_rule`):

```bash
<venv-python> -m agent_mem_bridge triggers matrix
<venv-python> -m agent_mem_bridge triggers install claude-code --yes
<venv-python> -m agent_mem_bridge triggers install cursor --yes
<venv-python> -m agent_mem_bridge triggers test claude-code
```

`triggers install` writes `.claude/settings.json`, `.cursor/hooks.json`, `.codex/hooks.json`, `AGENTS.md`, `.github/hooks/amb-triggers.json`, `.github/copilot-instructions.md`, `.clinerules/amb-triggers.md`, and `.cline/rules/amb-triggers.md`. New untracked project files from `connect` or `triggers install` mark the Git worktree dirty. `explore` and `inspect` report `dirty_worktree` until those files are committed or gitignored.

If an existing bridge lives at `~/.codex/mem-bridge`, v0.36+ does not open it automatically. Set `AGENT_MEMORY_BRIDGE_HOME` to that directory, or copy it to `~/.local/share/agent-memory-bridge`. The [configuration guide](docs/CONFIGURATION.md) has the cutover.

The companion skills are optional help for discovery and everyday use. They do not replace the startup rule above; see [trigger moments and hook recipes](https://github.com/zzhang82/Agent-Memory-Skills/blob/main/skills/amb-connect/references/lifecycle_and_hooks.md) for additional background. Install them from [Agent-Memory-Skills](https://github.com/zzhang82/Agent-Memory-Skills):

```bash
npx skills add zzhang82/Agent-Memory-Skills --skill amb
npx skills add zzhang82/Agent-Memory-Skills --skill amb-connect
```

- [`amb`](https://github.com/zzhang82/Agent-Memory-Skills/blob/main/skills/amb/SKILL.md) ([raw](https://raw.githubusercontent.com/zzhang82/Agent-Memory-Skills/main/skills/amb/SKILL.md))
- [`amb-connect`](https://github.com/zzhang82/Agent-Memory-Skills/blob/main/skills/amb-connect/SKILL.md) ([raw](https://raw.githubusercontent.com/zzhang82/Agent-Memory-Skills/main/skills/amb-connect/SKILL.md))

For a source checkout, install with `<venv-python> -m pip install -e .` instead of the pinned package.

Human-first Explore answers “What does AMB currently know?” Inspect answers “Why did this information surface?” Both are local and read-only. They are not the success check.

```bash
<venv-python> -m agent_mem_bridge explore --namespace project:my-app
<venv-python> -m agent_mem_bridge inspect \
  --namespace project:my-app \
  --query "What is required before we merge a pull request?"
```

Code tells AMB what the repository contains. A confirmed decision tells it why. Derived repository facts come from a clean Git commit. If HEAD moves or the worktree is dirty, refresh on purpose:

```bash
<venv-python> -m agent_mem_bridge bootstrap-repo . --namespace project:my-app
```

Refreshing repository facts leaves stored decisions unchanged. Explore is CLI-only. It is not an extra MCP tool.

`doctor` and `verify` check server prerequisites. They do not prove that a client loaded its MCP config. `first-run` is optional guided help, not the first-win path. Historical Codex observations from the v0.35 line are in [First-win acceptance](docs/FIRST-WIN-ACCEPTANCE.md).

</details>

## How a decision stays traceable

The useful part is not remembering more. It is knowing where a decision came from, whether it is still current, and how it changed.

| Memory concern | AMB approach |
|---|---|
| Current repository truth | Derived from a clean repository state and refreshed explicitly |
| Human decisions and constraints | Stored explicitly as governed durable memory |
| Changed knowledge | Revised or superseded instead of silently overwritten |
| Why context surfaced | Inspectable through local derived views and evidence paths |
| Cross-session reuse | Shared through the same configured local AMB home |
| Privacy | Local-first; no hosted memory service is required |

Code tells the next session what exists. AMB retains the confirmed reasons the code does not explain.

## What AMB is — and is not

AMB is a governed local project-memory layer for coding agents. Durable knowledge, derived repository facts, provenance, and corrections stay distinguishable.

It is not a transcript archive, a promise that an agent will remember everything, or a system that silently converts every conversation into durable truth. There is no automatic learning.

### Memory hygiene: Structure over prose

Do not treat memory as a prompt trash can for linter errors, directory conventions, or syntax dos and don'ts. If an agent makes the same mechanical mistake twice, harden the repository environment with linter rules, type guards, or pre-commit checks. Reserve AMB durable memory for the *reasons* that code cannot convey: architectural decisions, domain invariants, and third-party library gotchas. See the [Memory Hygiene Guide](docs/MEMORY-HYGIENE.md) for the 3-question ingestion filter.

## Want the details?

| Read | For |
|---|---|
| [Glossary](docs/GLOSSARY.md) | Plain-words feature names mapped to exact code, JSON, and MCP wire terms |
| [First-win demo](examples/demo/README.md) | The local two-process recording, and the older coordination demo |
| [First-win acceptance](docs/FIRST-WIN-ACCEPTANCE.md) | Historical Codex observation from the v0.35 line |
| [Architecture](docs/ARCHITECTURE.md) | System shape and data flow |
| [Authority model](docs/AUTHORITY-CONTRACT.md) | Durable authority, derived views, correction, and audit rules |
| [Knowledge Explorer](docs/KNOWLEDGE-EXPLORER.md) | Human-first read-only project view |
| [Memory Hygiene](docs/MEMORY-HYGIENE.md) | Anti-pollution rules and the structure-over-prose boundary |
| [Production Status](docs/PRODUCTION-STATUS.md) | Current implementation facts, evidence, and known limits |
| [Integrations](docs/INTEGRATIONS.md) | Generic stdio MCP installer contract |
| [Install for Agents](INSTALL_FOR_AGENTS.md) | Full install-to-first-success workflow |
| [Configuration](docs/CONFIGURATION.md) | Complete configuration reference |
| [Examples](examples/README.md) | Sanitized demos and artifacts |

## Technical model

Internally, AMB keeps code facts read from Git (`derived_repository`) separate from human-confirmed decisions (`governed_durable_memory`) so one cannot silently become the other. See the [Plain-Words to Code Glossary](docs/GLOSSARY.md) for the exact code and wire terms. For maintainers and reviewers, the current authority flow is:

```mermaid
flowchart LR
    A[Decisions & Rules / WHY] --> C[Current-Version Recall]
    B[Code Facts / WHAT] --> D[Context Compiler]
    S[Runtime State] --> D
    C --> E[Task Memory]
    E --> D
    D --> F[In-Memory Context]
    F --> G[Context Proof Receipt]
    G --> H[Tracked Work Runs]
    H --> I[Verification Receipt]
    I --> J[Verified Outcome]
```

SQLite/WAL rows are durable authority. Repository snapshots, FTS rows, embedding sidecars, compiled context, reports, and Explorer views are derived. Context bodies are rendered in process and are not durably persisted by the compiler.

## Optional HTTP gateway & deployment

AMB runs as a local-first stdio process by default, with an optional official **Streamable HTTP transport** and **Optional HTTP gateway**:

- **Local stdio**: no authentication or gateway configuration; it runs as before for individual agents.
- **Optional HTTP gateway**: per-client Bearer tokens, 4 roles (`admin`, `writer`, `reader`, `orchestrator`), namespace limits (`project:*`, `domain:*`), and structured JSONL audit lines.
- **Audit kept out of SQLite**: audit lines go to stdout, stderr or a file, not the database.

For remote server, NAS, or container setup, see [Remote Deployment](docs/REMOTE-DEPLOYMENT.md).

## Trust and privacy

AMB is local-first. It does not require a hosted memory service. It separates durable memory from coordination Signals and mutable Dynamic State, keeps provenance visible, and rejects raw transcripts, hidden reasoning, and inline artifact bodies from the durable episode path.

Read the [Trust Boundary](docs/TRUST-BOUNDARY.md), [Authority Contract](docs/AUTHORITY-CONTRACT.md), and [Closed-Loop Episode Authority](docs/CLOSED-LOOP-EPISODE.md) for the exact boundaries.

## MCP Tools

AMB exposes **17 public MCP tools**:

- `store`, `recall`, `browse`, and `stats`
- `forget`, `feedback`, `promote`, `annotate`, `revise`, and `export`
- `begin_run`, `record_run_event`, `get_run`, and `complete_run`
- `claim_signal`, `extend_signal_lease`, and `ack_signal`

The public tool surface stays small. Setup, Project Init, Explore, Inspect, context assembly, and review reports remain CLI or internal derived workflows rather than becoming more MCP tools.

The local protocol cache contract is `300000/public` for discovery and `0/private` for the tool list; see [MCP Compatibility](docs/MCP-2026-COMPATIBILITY.md) for details.

## Current maturity

Current package/source version is `0.39.1`. Schema remains v12 and the public MCP surface remains exactly 17 tools. There is no automatic learning and no MCP tool #18. `project init` is the preferred first-project path. Default Explore is a Human-first view over existing repository-derived context and governed project knowledge. Current evidence and non-claims live in [Production Status](docs/PRODUCTION-STATUS.md); published artifacts live in [GitHub Releases](https://github.com/zzhang82/Agent-Memory-Bridge/releases).

## Contributing

Read [CONTRIBUTING.md](CONTRIBUTING.md) for development and public-surface expectations, and [SECURITY.md](SECURITY.md) for vulnerability reporting.

Licensed under [MIT](LICENSE).

<!-- mcp-name: io.github.zzhang82/agent-memory-bridge -->
