Metadata-Version: 2.4
Name: local-agent-memory
Version: 1.0.2
Summary: Local notes for coding agents. Same project, next chat, still there. No account. Still hunting bugs; odd setups can be unstable.
Author: bang
License-Expression: MIT
Project-URL: Homepage, https://github.com/humer90000/agent-memory
Project-URL: Repository, https://github.com/humer90000/agent-memory
Project-URL: Issues, https://github.com/humer90000/agent-memory/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Topic :: Software Development
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# agent-memory

Notes for a coding agent, kept in the project, still there in the next chat.

You say "don't touch payments" once. Or the test command is `py -3`. Or yesterday's bug was a stale lock. The next chat in the same repo can search that back. The notes are a file on disk. Nothing is uploaded. There is no account.

Looking for bugs in real use. Unusual cases can still be unstable: a hand-edited notes file, a link where `.agent-memory` should be, an editor config that isn't plain JSON.

This does not read the repo and decide what to remember. A note exists because `memory_save` was called. It also does not trim diffs or logs. Different job.

Python 3.9 or newer. No packages required. MIT.

## what you get

Four tools. The editor calls them. There is no chat window of ours.

`memory_save` stores one note and returns its id. A tag is optional, a short word like `payments` or `tests`.

`memory_search` looks for those words in the text and the tag. At most 8 hits, newest first. Words, not embeddings. No model, no vector database.

`memory_list` returns the latest notes. 20 if you don't pass a limit.

`memory_forget` deletes one note by id. A missing id is an error the agent can read. The process keeps running.

From a terminal, same store:

```
py -3 agent_memory.py save "do not touch the payments folder" --tag payments
py -3 agent_memory.py search payments
```

That session, on this machine:

![save, then search payments](https://github.com/humer90000/agent-memory/raw/master/img/search.png)

The file it wrote:

![.agent-memory/notes.jsonl](https://github.com/humer90000/agent-memory/raw/master/img/notes.png)

One JSON object per line. `id`, `text`, `tag`, `created`. Open it in an editor if you don't trust the tool.

## how it stays running

You don't start the server. The editor does, over stdin and stdout, the usual MCP shape. Cursor, VS Code, Claude Code, Claude Desktop, and Codex all talk to the same process. Only the config file is different.

Stdout is JSON only. Debug goes to stderr. The empty lists those editors ask for (`prompts/list`, `resources/list`, `resources/templates/list`) get an empty answer, so they don't mark the server dead. The protocol version the client sent is the one we send back.

Once it's hooked up, the agent is told to save a fact the next chat would otherwise have to hear again, to search before asking the repo the same question twice, and to leave tokens out. You don't paste the warning into every new chat.

The notes for a project live here:

```
.agent-memory/
  notes.jsonl
```

`setup --write`, and the first save, add `.agent-memory/` to `.gitignore` if that line isn't already there. The rest of a gitignore you wrote stays. If you want the notes in git, delete that line yourself.

A save is written to a temp file and renamed into place. A crash mid-write doesn't leave a half line for the next search to choke on.

A path outside the project is an error. So is a link sitting on `.agent-memory` or on the notes file. One of those pointed at `src/` and the next save wrote `notes.jsonl` in there. The tool does not follow it.

## secrets

A note that looks like a secret is refused and not written.

- a GitHub token, `ghp_` or `github_pat_`, with a real run of characters after it
- an OpenAI-style key, `sk-` plus a run of characters that includes a digit. `sk-learn` and a word like `sk-projection` are notes
- a line that looks like a `.env` assignment of a token, password, or secret (`DB_PASSWORD=hunter2`, `export API_TOKEN=...`)

A normal sentence that says the word "password" is fine. "ask-the reviewer" is fine too. The check is the shape of a secret, not the English word. The error that comes back does not repeat the secret.

## install

On Windows, `python` from the store is a stub and sits there doing nothing. Use `py -3`. If your `python` actually runs, the snippet on that machine still uses `py -3` on purpose.

```
py -3 -m pip install local-agent-memory
agent-memory --version
```

PyPI already has another project under `agentmemory`, so the install name here is `local-agent-memory`. The command is still `agent-memory`.

From a checkout of this repo, `py -3 -m pip install -e .` is the same program. Without installing, `py -3 agent_memory.py` from this folder works too. The editor config points at that file. If you move the checkout, run setup again.

<!-- was: pip install agent-memory. pypi rejected the name, too similar to agentmemory -->
<!-- agentmemory and agent-memory-engine are other programs, not this one -->

Tests, if you want them:

```
py -3 -m unittest discover -s tests
```

## hook it up

Run it from the project. That's the folder that gets the `.gitignore` line. VS Code and Claude Code also write their config into that folder. Cursor, Claude Desktop, and Codex use the user config instead.

Print the snippet. Nothing is written yet.

```
py -3 agent_memory.py setup
py -3 agent_memory.py setup vscode
py -3 agent_memory.py setup claude
py -3 agent_memory.py setup claude-desktop
py -3 agent_memory.py setup codex
```

Merge it into the file the editor already has. Other servers stay. Codex is toml, so `--write` appends one block and will not add a second one.

```
py -3 agent_memory.py setup cursor --write
py -3 agent_memory.py setup vscode --write
py -3 agent_memory.py setup claude --write
py -3 agent_memory.py setup claude-desktop --write
py -3 agent_memory.py setup codex --write
```

Where that goes:

- Cursor: `%USERPROFILE%\.cursor\mcp.json`, key `mcpServers`
- VS Code: `.vscode/mcp.json` in this folder, key `servers`, type `stdio`
- Claude Code: `.mcp.json` in this folder, key `mcpServers`
- Claude Desktop: `%APPDATA%\Claude\claude_desktop_config.json`
- Codex: `%USERPROFILE%\.codex\config.toml`, a `[mcp_servers.agent-memory]` block

Restart the editor after. It does not always pick up a config that's already open. Then the tools show up as `memory_save`, `memory_search`, `memory_list`, `memory_forget`. If they don't, restart once more. Don't run `agent_memory.py mcp` yourself unless you're debugging the pipe.

Cursor's snippet looks like this. The path is wherever you left the file.

```json
{
  "mcpServers": {
    "agent-memory": {
      "command": "py",
      "args": ["-3", "W:\\Projects\\agent-memory\\agent_memory.py", "mcp"]
    }
  }
}
```

## limits

One note is cut at 2000 characters. The reply says it was cut.

500 notes in one project, then a new save is refused until you forget one.

Search returns at most 8.

The store is the folder the editor started in, or a folder you passed that is inside it.

## not in this version

Pictures, voice, one memory for every project on the machine, search by meaning, a website, an account, sync between computers. Those wait until the four tools are actually getting used.

No network call. Unplugging the cable doesn't change save or search. There is no port to bind.
