hermes-brain-memory 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ dist/
2
+ build/
3
+ .venv*/
4
+ __pycache__/
5
+ *.egg-info/
6
+ *.pyc
@@ -0,0 +1,14 @@
1
+ # Changelog — hermes-brain-memory
2
+
3
+ ## 0.1.0 (2026-07-04)
4
+
5
+ Initial release.
6
+
7
+ - Vendors the Brain Memory provider for Hermes Agent (provider payload v1.0.0,
8
+ stdlib only): `brain_recall` / `brain_memorize` / `brain_reinforce` tools,
9
+ budget-bounded session-start context, background prefetch, pre-compression
10
+ reminder, session-context logging, MEMORY.md mirroring, `backup_paths()`.
11
+ - `hermes-brain-memory` console script with `install` (idempotent, `--force`),
12
+ `uninstall`, and `status` subcommands targeting `$HERMES_HOME/plugins/brain`
13
+ (mechanism mirrors the `hermes-memori` precedent).
14
+ - Verified live end-to-end on Hermes Agent v0.18.0.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omelas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: hermes-brain-memory
3
+ Version: 0.1.0
4
+ Summary: Brain Memory provider for Hermes Agent — local-first, cross-agent Markdown memory (~/.brain) shared with Claude Code, Codex, OpenCode, and OpenClaw. No runtime dependencies.
5
+ Project-URL: Homepage, https://brainmemory.ai
6
+ Project-URL: Repository, https://github.com/omelas-tech/brain
7
+ Project-URL: Documentation, https://brainmemory.ai
8
+ Project-URL: Changelog, https://github.com/omelas-tech/brain/blob/main/integrations/hermes/package/CHANGELOG.md
9
+ Author-email: Omelas <onur@omelas.tech>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agent-memory,brain-memory,hermes,hermes-agent,local-first,memory,memory-provider,plugin
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: End Users/Desktop
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+
28
+ # hermes-brain-memory
29
+
30
+ **[Brain Memory](https://brainmemory.ai) provider for [Hermes Agent](https://hermes-agent.nousresearch.com)** — one local-first memory shared across all your AI agents. The same human-readable Markdown store in `~/.brain/` is read and written by Claude Code, Codex, OpenCode, and OpenClaw, so Hermes remembers what your other agents learned — and vice versa.
31
+
32
+ Memories are plain Markdown files with YAML frontmatter (greppable, diffable, editable). They decay over time, strengthen with use (spaced reinforcement), and connect through an associative network with spreading activation. The model decides *what* to remember via explicit tools; the `brain` CLI scores recall deterministically.
33
+
34
+ **Zero pip dependencies** — this package and the provider it installs are Python stdlib only.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ # 1. The brain CLI (once, if you don't already use Brain Memory)
40
+ npm install -g brain-memory
41
+
42
+ # 2. This package + the provider
43
+ pip install hermes-brain-memory # or: uv tool install / pipx install hermes-brain-memory
44
+ hermes-brain-memory install # copies the provider into $HERMES_HOME/plugins/brain
45
+ ```
46
+
47
+ ## Activate
48
+
49
+ ```bash
50
+ hermes config set memory.provider brain
51
+ hermes memory setup # optional guided configuration
52
+ hermes memory status # verify: "brain" should show as installed & available
53
+ ```
54
+
55
+ Or set it directly in `$HERMES_HOME/config.yaml` (usually `~/.hermes/config.yaml`):
56
+
57
+ ```yaml
58
+ memory:
59
+ provider: brain
60
+ ```
61
+
62
+ Only one external memory provider can be active at a time; Hermes' built-in MEMORY.md/USER.md memory keeps running alongside.
63
+
64
+ ## What it does
65
+
66
+ | Lifecycle | Behavior |
67
+ |---|---|
68
+ | Session start | Injects a budget-bounded context block from `brain session-start`: status line, pinned facts, procedural-skills index, relevant memory titles, memorize guidance |
69
+ | Pre-turn | Prefetches relevant memories for the user's message (background thread, non-blocking) |
70
+ | Tools | `brain_recall` (deterministic recall + full bodies + auto-reinforce), `brain_memorize` (validated store), `brain_reinforce` (spaced reinforcement by ID) |
71
+ | Pre-compression | Reminds the model to store un-memorized notable content before context is discarded |
72
+ | Session end | Appends a session entry to `~/.brain/contexts.json` (last 20 kept) |
73
+ | Built-in memory writes | Mirrors MEMORY.md entries into `~/.brain` as content-hash-deduplicated observations |
74
+ | Backup | `~/.brain` is declared via `backup_paths()` so `hermes backup` captures it |
75
+
76
+ No transcript dumping: `sync_turn` does lightweight in-memory topic tracking only. Nothing leaves the machine unless you enable Brain's own sync (Brain Cloud or a private Git remote).
77
+
78
+ ## Installer commands
79
+
80
+ ```bash
81
+ hermes-brain-memory install [--force] # copy/update the provider (idempotent; --force overwrites)
82
+ hermes-brain-memory uninstall # remove it ($HERMES_HOME/plugins/brain only — ~/.brain is untouched)
83
+ hermes-brain-memory status # install state, brain CLI, active memory.provider
84
+ ```
85
+
86
+ `HERMES_HOME` (or `--hermes-home PATH`) selects the Hermes profile to install into; default `~/.hermes`.
87
+
88
+ ## Configuration
89
+
90
+ Stored in `$HERMES_HOME/brain.json` (written by `hermes memory setup`); environment variables override.
91
+
92
+ | Key | Default | Env var | Description |
93
+ |---|---|---|---|
94
+ | `project` | `hermes` | `BRAIN_PROJECT` | Project label for context-dependent recall |
95
+ | `top_recall` | `6` | `BRAIN_TOP_RECALL` | Max memories per recall (1–25) |
96
+ | `auto_reinforce` | `true` | `BRAIN_AUTO_REINFORCE` | Reinforce memories surfaced by `brain_recall` |
97
+ | `brain_bin` | `brain` | `BRAIN_BIN` | Path to the brain CLI |
98
+ | `sync_on_memorize` | `false` | `BRAIN_SYNC_ON_MEMORIZE` | Push each store to Brain Cloud / Git remote |
99
+
100
+ ## Requirements
101
+
102
+ - [Hermes Agent](https://hermes-agent.nousresearch.com) (a version with pluggable memory providers)
103
+ - The `brain` CLI from the [`brain-memory`](https://www.npmjs.com/package/brain-memory) npm package
104
+ - Python 3.10+ — no pip dependencies
105
+
106
+ ## Docs & source
107
+
108
+ - Brain Memory: [brainmemory.ai](https://brainmemory.ai)
109
+ - Source & full integration docs: [github.com/omelas-tech/brain](https://github.com/omelas-tech/brain) (`integrations/hermes/`)
110
+ - Hermes memory providers: [hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers](https://hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers)
111
+
112
+ ## License
113
+
114
+ MIT © Omelas
@@ -0,0 +1,87 @@
1
+ # hermes-brain-memory
2
+
3
+ **[Brain Memory](https://brainmemory.ai) provider for [Hermes Agent](https://hermes-agent.nousresearch.com)** — one local-first memory shared across all your AI agents. The same human-readable Markdown store in `~/.brain/` is read and written by Claude Code, Codex, OpenCode, and OpenClaw, so Hermes remembers what your other agents learned — and vice versa.
4
+
5
+ Memories are plain Markdown files with YAML frontmatter (greppable, diffable, editable). They decay over time, strengthen with use (spaced reinforcement), and connect through an associative network with spreading activation. The model decides *what* to remember via explicit tools; the `brain` CLI scores recall deterministically.
6
+
7
+ **Zero pip dependencies** — this package and the provider it installs are Python stdlib only.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ # 1. The brain CLI (once, if you don't already use Brain Memory)
13
+ npm install -g brain-memory
14
+
15
+ # 2. This package + the provider
16
+ pip install hermes-brain-memory # or: uv tool install / pipx install hermes-brain-memory
17
+ hermes-brain-memory install # copies the provider into $HERMES_HOME/plugins/brain
18
+ ```
19
+
20
+ ## Activate
21
+
22
+ ```bash
23
+ hermes config set memory.provider brain
24
+ hermes memory setup # optional guided configuration
25
+ hermes memory status # verify: "brain" should show as installed & available
26
+ ```
27
+
28
+ Or set it directly in `$HERMES_HOME/config.yaml` (usually `~/.hermes/config.yaml`):
29
+
30
+ ```yaml
31
+ memory:
32
+ provider: brain
33
+ ```
34
+
35
+ Only one external memory provider can be active at a time; Hermes' built-in MEMORY.md/USER.md memory keeps running alongside.
36
+
37
+ ## What it does
38
+
39
+ | Lifecycle | Behavior |
40
+ |---|---|
41
+ | Session start | Injects a budget-bounded context block from `brain session-start`: status line, pinned facts, procedural-skills index, relevant memory titles, memorize guidance |
42
+ | Pre-turn | Prefetches relevant memories for the user's message (background thread, non-blocking) |
43
+ | Tools | `brain_recall` (deterministic recall + full bodies + auto-reinforce), `brain_memorize` (validated store), `brain_reinforce` (spaced reinforcement by ID) |
44
+ | Pre-compression | Reminds the model to store un-memorized notable content before context is discarded |
45
+ | Session end | Appends a session entry to `~/.brain/contexts.json` (last 20 kept) |
46
+ | Built-in memory writes | Mirrors MEMORY.md entries into `~/.brain` as content-hash-deduplicated observations |
47
+ | Backup | `~/.brain` is declared via `backup_paths()` so `hermes backup` captures it |
48
+
49
+ No transcript dumping: `sync_turn` does lightweight in-memory topic tracking only. Nothing leaves the machine unless you enable Brain's own sync (Brain Cloud or a private Git remote).
50
+
51
+ ## Installer commands
52
+
53
+ ```bash
54
+ hermes-brain-memory install [--force] # copy/update the provider (idempotent; --force overwrites)
55
+ hermes-brain-memory uninstall # remove it ($HERMES_HOME/plugins/brain only — ~/.brain is untouched)
56
+ hermes-brain-memory status # install state, brain CLI, active memory.provider
57
+ ```
58
+
59
+ `HERMES_HOME` (or `--hermes-home PATH`) selects the Hermes profile to install into; default `~/.hermes`.
60
+
61
+ ## Configuration
62
+
63
+ Stored in `$HERMES_HOME/brain.json` (written by `hermes memory setup`); environment variables override.
64
+
65
+ | Key | Default | Env var | Description |
66
+ |---|---|---|---|
67
+ | `project` | `hermes` | `BRAIN_PROJECT` | Project label for context-dependent recall |
68
+ | `top_recall` | `6` | `BRAIN_TOP_RECALL` | Max memories per recall (1–25) |
69
+ | `auto_reinforce` | `true` | `BRAIN_AUTO_REINFORCE` | Reinforce memories surfaced by `brain_recall` |
70
+ | `brain_bin` | `brain` | `BRAIN_BIN` | Path to the brain CLI |
71
+ | `sync_on_memorize` | `false` | `BRAIN_SYNC_ON_MEMORIZE` | Push each store to Brain Cloud / Git remote |
72
+
73
+ ## Requirements
74
+
75
+ - [Hermes Agent](https://hermes-agent.nousresearch.com) (a version with pluggable memory providers)
76
+ - The `brain` CLI from the [`brain-memory`](https://www.npmjs.com/package/brain-memory) npm package
77
+ - Python 3.10+ — no pip dependencies
78
+
79
+ ## Docs & source
80
+
81
+ - Brain Memory: [brainmemory.ai](https://brainmemory.ai)
82
+ - Source & full integration docs: [github.com/omelas-tech/brain](https://github.com/omelas-tech/brain) (`integrations/hermes/`)
83
+ - Hermes memory providers: [hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers](https://hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers)
84
+
85
+ ## License
86
+
87
+ MIT © Omelas
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hermes-brain-memory"
7
+ version = "0.1.0"
8
+ description = "Brain Memory provider for Hermes Agent — local-first, cross-agent Markdown memory (~/.brain) shared with Claude Code, Codex, OpenCode, and OpenClaw. No runtime dependencies."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Omelas", email = "onur@omelas.tech" }]
13
+ requires-python = ">=3.10"
14
+ dependencies = []
15
+ keywords = [
16
+ "hermes-agent",
17
+ "hermes",
18
+ "memory",
19
+ "memory-provider",
20
+ "brain-memory",
21
+ "agent-memory",
22
+ "local-first",
23
+ "plugin",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 4 - Beta",
27
+ "Environment :: Console",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: End Users/Desktop",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
37
+ "Topic :: Utilities",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://brainmemory.ai"
42
+ Repository = "https://github.com/omelas-tech/brain"
43
+ Documentation = "https://brainmemory.ai"
44
+ Changelog = "https://github.com/omelas-tech/brain/blob/main/integrations/hermes/package/CHANGELOG.md"
45
+
46
+ [project.scripts]
47
+ hermes-brain-memory = "hermes_brain_memory.installer:main"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["src/hermes_brain_memory"]
51
+
52
+ [tool.hatch.build.targets.sdist]
53
+ include = [
54
+ "src/hermes_brain_memory",
55
+ "tests",
56
+ "README.md",
57
+ "CHANGELOG.md",
58
+ "LICENSE",
59
+ "pyproject.toml",
60
+ ]
61
+ exclude = ["**/__pycache__", "**/*.pyc", ".gitignore"]
@@ -0,0 +1,18 @@
1
+ """hermes-brain-memory — Brain Memory provider for Hermes Agent.
2
+
3
+ This package is an *installer + payload*: it vendors the Brain Memory
4
+ provider (a Hermes ``exclusive``/memory plugin, stdlib only) and ships the
5
+ ``hermes-brain-memory`` console script that copies it into
6
+ ``$HERMES_HOME/plugins/brain/``, where Hermes' user-plugin memory discovery
7
+ picks it up.
8
+
9
+ The provider itself lives in ``_vendor/brain/`` and is deliberately
10
+ self-contained — Hermes loads it from the plugins directory, never through
11
+ this package's import path.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ __version__ = "0.1.0"
17
+
18
+ __all__ = ["__version__"]
@@ -0,0 +1,51 @@
1
+ # Brain Memory provider for Hermes Agent
2
+
3
+ Backs Hermes Agent's memory slot with [Brain Memory](https://brainmemory.ai) — a local-first, human-readable Markdown memory store in `~/.brain/`, shared across Hermes, Claude Code, Codex, OpenCode, and OpenClaw. Memories decay, strengthen with use, and connect through an associative network — the model decides *what* to remember; the `brain` CLI handles the plumbing deterministically.
4
+
5
+ ## Requirements
6
+
7
+ - The `brain` CLI: `npm install -g brain-memory` (then run its installer once so `~/.brain/` exists)
8
+ - Python 3.10+ (no pip dependencies)
9
+
10
+ ## Setup
11
+
12
+ 1. Copy this directory to `$HERMES_HOME/plugins/brain/` (usually `~/.hermes/plugins/brain/`), or use it in-tree at `plugins/memory/brain/`.
13
+ 2. Activate it:
14
+
15
+ ```bash
16
+ hermes memory setup # guided
17
+ ```
18
+
19
+ or in `~/.hermes/config.yaml`:
20
+
21
+ ```yaml
22
+ memory:
23
+ provider: brain
24
+ ```
25
+
26
+ 3. Verify: `hermes memory status`
27
+
28
+ ## What it does
29
+
30
+ | Lifecycle | Behavior |
31
+ |---|---|
32
+ | Session start | Injects a budget-bounded context block from `brain session-start`: status line, pinned facts, skills index, relevant memory titles, memorize guidance |
33
+ | Pre-turn | Prefetches relevant memories for the user's message (background thread) |
34
+ | Tools | `brain_recall` (recall + auto-reinforce + full bodies), `brain_memorize` (validated store), `brain_reinforce` |
35
+ | Pre-compression | Reminds the model to store un-memorized notable content before context is discarded |
36
+ | Session end | Appends a session entry to `~/.brain/contexts.json` (last 20 kept) |
37
+ | Built-in memory writes | Mirrors MEMORY.md entries into `~/.brain` as deduplicated observations |
38
+
39
+ ## Configuration
40
+
41
+ Stored in `$HERMES_HOME/brain.json`; environment variables override defaults.
42
+
43
+ | Key | Default | Env var | Description |
44
+ |---|---|---|---|
45
+ | `project` | `hermes` | `BRAIN_PROJECT` | Project label for context-dependent recall |
46
+ | `top_recall` | `6` | `BRAIN_TOP_RECALL` | Max memories per recall (1–25) |
47
+ | `auto_reinforce` | `true` | `BRAIN_AUTO_REINFORCE` | Reinforce memories surfaced by `brain_recall` |
48
+ | `brain_bin` | `brain` | `BRAIN_BIN` | Path to the brain CLI |
49
+ | `sync_on_memorize` | `false` | `BRAIN_SYNC_ON_MEMORIZE` | Push each store to Brain Cloud / Git remote |
50
+
51
+ The built-in MEMORY.md/USER.md memory keeps running alongside — this provider supplements it with a long-lived, cross-agent store. See `integrations/hermes/README.md` in the brain-memory repository for hooks-based and MCP-based alternatives.
@@ -0,0 +1,31 @@
1
+ """Brain Memory provider plugin for Hermes Agent.
2
+
3
+ Local-first, human-readable Markdown memory (~/.brain) shared across Hermes,
4
+ Claude Code, Gemini CLI, Codex, OpenCode, and OpenClaw. See README.md.
5
+ """
6
+
7
+ try:
8
+ # Normal case: loaded as a package (in-tree plugins/memory/brain or
9
+ # $HERMES_HOME/plugins/brain when the loader imports the package).
10
+ from .provider import BrainMemoryProvider
11
+ except ImportError: # pragma: no cover
12
+ # Fallback: some loaders exec __init__.py as a standalone module, which
13
+ # breaks relative imports. Load provider.py from the same directory.
14
+ import importlib.util as _ilu
15
+ import os as _os
16
+
17
+ _spec = _ilu.spec_from_file_location(
18
+ "hermes_brain_memory_provider",
19
+ _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), "provider.py"),
20
+ )
21
+ _mod = _ilu.module_from_spec(_spec)
22
+ assert _spec.loader is not None
23
+ _spec.loader.exec_module(_mod)
24
+ BrainMemoryProvider = _mod.BrainMemoryProvider
25
+
26
+ __all__ = ["BrainMemoryProvider", "register"]
27
+
28
+
29
+ def register(ctx) -> None:
30
+ """Register Brain Memory as a memory provider plugin."""
31
+ ctx.register_memory_provider(BrainMemoryProvider())
@@ -0,0 +1,119 @@
1
+ """Standalone diagnostics CLI for the Brain Memory provider.
2
+
3
+ Hermes loads user-installed memory providers through its memory-discovery
4
+ path, whose plugin context only accepts ``register_memory_provider`` — it has
5
+ no CLI registration (that API belongs to regular, non-exclusive plugins). So
6
+ these commands run as a plain module instead:
7
+
8
+ python3 ~/.hermes/plugins/brain/cli.py status
9
+ python3 ~/.hermes/plugins/brain/cli.py recall "what did we decide about X"
10
+
11
+ ``register_cli(subparser)`` is kept for a possible future in-tree bundling
12
+ where a real CLI hook exists. Stdlib only; shells out to the ``brain`` CLI
13
+ (brain-memory npm package). In-session, use the provider's ``brain_recall`` /
14
+ ``brain_memorize`` tools — the agent calls those itself.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import os
21
+ import shutil
22
+ import subprocess
23
+ from pathlib import Path
24
+
25
+ try:
26
+ from .provider import BrainMemoryProvider, brain_dir
27
+ except ImportError: # pragma: no cover — standalone loading
28
+ import importlib.util as _ilu
29
+
30
+ _spec = _ilu.spec_from_file_location(
31
+ "hermes_brain_memory_provider_cli",
32
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), "provider.py"),
33
+ )
34
+ _mod = _ilu.module_from_spec(_spec)
35
+ assert _spec.loader is not None
36
+ _spec.loader.exec_module(_mod)
37
+ BrainMemoryProvider = _mod.BrainMemoryProvider
38
+ brain_dir = _mod.brain_dir
39
+
40
+
41
+ def _brain_bin() -> str:
42
+ return os.environ.get("BRAIN_BIN", "brain")
43
+
44
+
45
+ def _cmd_status(args) -> int:
46
+ bin_name = _brain_bin()
47
+ found = shutil.which(bin_name) or (os.path.isfile(os.path.expanduser(bin_name)) and bin_name)
48
+ store = brain_dir()
49
+ index = store / "index.json"
50
+ print(f"brain CLI : {found or 'NOT FOUND (npm install -g brain-memory)'}")
51
+ print(f"store : {store} ({'present' if store.exists() else 'missing'})")
52
+ print(f"index.json : {'present' if index.exists() else 'missing'}")
53
+ if found and index.exists():
54
+ try:
55
+ env = dict(os.environ)
56
+ env["BRAIN_AGENT"] = "hermes"
57
+ proc = subprocess.run(
58
+ [bin_name, "session-start", "--project", os.environ.get("BRAIN_PROJECT", "hermes")],
59
+ capture_output=True,
60
+ text=True,
61
+ timeout=15,
62
+ env=env,
63
+ )
64
+ if proc.returncode == 0:
65
+ payload = json.loads(proc.stdout)
66
+ print(f"memories : {payload.get('memory_count', '?')}")
67
+ print(f"pinned : {len(payload.get('pinned') or [])}")
68
+ print(f"skills : {len(payload.get('skills_index') or [])}")
69
+ except (OSError, subprocess.TimeoutExpired, ValueError):
70
+ print("memories : (could not query)")
71
+ return 0
72
+
73
+
74
+ def _cmd_recall(args) -> int:
75
+ provider = BrainMemoryProvider()
76
+ provider.initialize("cli", hermes_home=os.environ.get("HERMES_HOME", ""))
77
+ print(
78
+ provider.handle_tool_call(
79
+ "brain_recall",
80
+ {"query": " ".join(args.query), "reinforce": False},
81
+ )
82
+ )
83
+ return 0
84
+
85
+
86
+ def _dispatch(args) -> int:
87
+ command = getattr(args, "brain_command", None)
88
+ if command == "status":
89
+ return _cmd_status(args)
90
+ if command == "recall":
91
+ return _cmd_recall(args)
92
+ print("usage: hermes memory {status|recall <query>}")
93
+ return 1
94
+
95
+
96
+ def register_cli(subparser) -> None:
97
+ """Attach brain subcommands to an argparse subparser (in-tree use only —
98
+ Hermes exposes no CLI hook to user-installed memory providers)."""
99
+ subs = subparser.add_subparsers(dest="brain_command")
100
+ subs.add_parser("status", help="Show Brain Memory store status")
101
+ recall = subs.add_parser("recall", help="Recall memories from ~/.brain")
102
+ recall.add_argument("query", nargs="+", help="What to recall")
103
+ subparser.set_defaults(func=_dispatch)
104
+
105
+
106
+ def main(argv=None) -> int:
107
+ import argparse
108
+
109
+ parser = argparse.ArgumentParser(
110
+ prog="brain-provider",
111
+ description="Brain Memory provider diagnostics (standalone)",
112
+ )
113
+ register_cli(parser)
114
+ args = parser.parse_args(argv)
115
+ return _dispatch(args)
116
+
117
+
118
+ if __name__ == "__main__":
119
+ raise SystemExit(main())
@@ -0,0 +1,7 @@
1
+ name: brain
2
+ version: 1.0.0
3
+ description: "Brain Memory — local-first, human-readable Markdown memory (~/.brain) with decay, spreading activation, and spaced reinforcement, shared across Hermes, Claude Code, Codex, OpenCode, and OpenClaw."
4
+ hooks:
5
+ - on_session_end
6
+ - on_pre_compress
7
+ - on_memory_write