Skip to content

Commit 69ca71b

Browse files
authored
feat: integrate external Brain memory bridge
Adds optional external Brain CLI/MCP integration, installed project bridge tooling, the Brain seed skill, v0.18.0 release docs/version text, and regression coverage.
1 parent a2c6f88 commit 69ca71b

15 files changed

Lines changed: 583 additions & 19 deletions

.agent/AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Daily driver, highest-leverage first:
7878
protocol for patterns the dream cycle has staged.
7979
- `retract_lesson.py <lesson_id> --rationale "..."` — stop an accepted lesson
8080
from being injected into future recall/context while preserving audit history.
81+
- `brain_bridge.py ask|note|status` — optional bridge to the external Brain
82+
CLI for git-backed long-term memory shared across harnesses.
8183
- `memory_reflect.py <skill> <action> <outcome>` — log a significant event.
8284

8385
## Rules

.agent/skills/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ Triggers: "data flywheel", "trace to train", "training traces",
4545
Constraints: local-only by default; human-approved runs only; redaction required
4646
before trainable; does not train models.
4747

48+
## brain
49+
Connects agentic-stack projects to the external Brain CLI and MCP server for
50+
git-backed long-term memory shared across harnesses.
51+
Triggers: "brain", "long-term memory", "shared memory", "cross-agent memory",
52+
"mcp memory", "remember across tools", "git-backed memory"
53+
Constraints: Brain is external; check availability before use, do not store
54+
secrets, and use `brain_bridge.py ask` before saving new durable notes.
55+
4856
## design-md
4957
Uses a root `DESIGN.md` as the portable visual system contract for
5058
Google Stitch workflows. Loads only when `DESIGN.md` exists at the

.agent/skills/_manifest.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
{"name":"deploy-checklist","version":"2026-01-01","triggers":["deploy","ship","release","go live"],"tools":["bash"],"preconditions":[],"constraints":["all tests passing","no unresolved TODOs in diff","requires human approval for production"],"category":"operations"}
66
{"name":"data-layer","version":"2026-04-26","triggers":["data layer","dashboard","show me the dashboard","what did my agents do","agent analytics","agent status","resource usage","usage report","cron monitoring","daily report","tokens","terminal dashboard","TUI"],"tools":["bash","git"],"preconditions":[".agent exists"],"constraints":["local-only by default","no screenshot delivery without explicit user approval","do not commit private .agent/data-layer exports"],"category":"operations"}
77
{"name":"data-flywheel","version":"2026-04-25","triggers":["data flywheel","trace to train","training traces","context cards","eval cases","approved runs","vertical intelligence"],"tools":["bash","git"],"preconditions":[".agent exists"],"constraints":["local-only by default","human-approved runs only","redaction required before trainable","do not train models"],"category":"operations"}
8+
{"name":"brain","version":"2026-05-10","triggers":["brain","long-term memory","shared memory","cross-agent memory","mcp memory","remember across tools","git-backed memory"],"tools":["bash"],"preconditions":[".agent exists"],"constraints":["Brain is external; do not assume the brain binary is installed","do not store secrets in Brain","use ask before note when checking prior context"],"category":"memory"}
89
{"name":"design-md","version":"2026-04-26","triggers":["DESIGN.md","design.md","Google Stitch","Stitch","design tokens","design system","visual design"],"tools":["bash","memory_reflect"],"preconditions":["DESIGN.md exists at project root"],"constraints":["prefer DESIGN.md tokens over invented values","do not modify DESIGN.md unless the user explicitly asks","preserve unknown sections when an edit IS authorised","validate when tooling is available"],"category":"design"}
910
{"name":"tldraw","version":"2026-04-21","triggers":["draw","diagram","sketch","wireframe","flowchart","mind-map","mind map","visualize","lay out","architecture diagram","whiteboard"],"tools":["mcp.tldraw.create_shape","mcp.tldraw.update_shape","mcp.tldraw.delete_shape","mcp.tldraw.get_canvas"],"preconditions":["tldraw MCP server reachable","user has http://localhost:3030 open"],"constraints":["call get_canvas before update_shape or delete_shape","at most 200 shapes per create_shape call","coordinates within 0..1600 x 0..900 unless told otherwise"],"category":"visualization","feature_flag":"tldraw"}

.agent/skills/brain/SKILL.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: brain
3+
version: 2026-05-10
4+
triggers: ["brain", "long-term memory", "shared memory", "cross-agent memory", "mcp memory", "remember across tools", "git-backed memory"]
5+
tools: [bash]
6+
preconditions: [".agent exists"]
7+
constraints: ["Brain is external; do not assume the brain binary is installed", "do not store secrets in Brain", "use ask before note when checking prior context"]
8+
category: memory
9+
---
10+
11+
# Brain Integration
12+
13+
Use this skill when the task needs durable memory shared across coding-agent
14+
harnesses through the external `brain` CLI and MCP server.
15+
16+
## Check Availability
17+
18+
```bash
19+
python3 .agent/tools/brain_bridge.py status
20+
```
21+
22+
If Brain is missing, tell the user to install it:
23+
24+
```bash
25+
brew install codejunkie99/tap/brain
26+
```
27+
28+
## Recall
29+
30+
Before non-trivial work that could depend on prior cross-tool decisions:
31+
32+
```bash
33+
python3 .agent/tools/brain_bridge.py ask "<intent or topic>"
34+
```
35+
36+
Use returned notes as context, but keep project-local `.agent/memory/semantic`
37+
as the source for agentic-stack lessons until the user explicitly asks to
38+
promote or migrate them.
39+
40+
## Save
41+
42+
Save one concise observation when the user gives a durable preference,
43+
cross-project convention, or decision that should survive across harnesses:
44+
45+
```bash
46+
python3 .agent/tools/brain_bridge.py note "<one durable observation>"
47+
```
48+
49+
Do not save secrets, credentials, or ephemeral task details.
50+
51+
## MCP
52+
53+
To wire Brain as an MCP stdio server, inspect:
54+
55+
```bash
56+
python3 .agent/tools/brain_bridge.py mcp-command
57+
```
58+
59+
The expected command is `brain serve --mcp`.

.agent/tools/brain_bridge.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python3
2+
"""Host-agent bridge to the external Brain CLI.
3+
4+
This script is copied into installed projects by `agentic-stack upgrade`. It
5+
keeps agent instructions stable even though Brain itself is a separate Rust
6+
binary and release stream.
7+
"""
8+
from __future__ import annotations
9+
10+
import argparse
11+
import os
12+
import shutil
13+
import subprocess
14+
import sys
15+
from pathlib import Path
16+
17+
18+
INSTALL_HINT = """brain CLI not found.
19+
20+
Install Brain:
21+
brew install codejunkie99/tap/brain
22+
23+
Or set:
24+
AGENTIC_STACK_BRAIN_BIN=/path/to/brain
25+
"""
26+
27+
28+
def main(argv: list[str] | None = None) -> int:
29+
parser = argparse.ArgumentParser(description="Bridge .agent workflows to Brain.")
30+
sub = parser.add_subparsers(dest="command", required=True)
31+
sub.add_parser("status")
32+
sub.add_parser("log")
33+
doctor = sub.add_parser("doctor")
34+
doctor.add_argument("--deep", action="store_true")
35+
ask = sub.add_parser("ask")
36+
ask.add_argument("query", nargs=argparse.REMAINDER)
37+
note = sub.add_parser("note")
38+
note.add_argument("text", nargs=argparse.REMAINDER)
39+
sub.add_parser("mcp-command")
40+
41+
args = parser.parse_args(argv)
42+
brain = _brain_bin()
43+
if brain is None:
44+
print(INSTALL_HINT.rstrip(), file=sys.stderr)
45+
return 2
46+
47+
if args.command == "status":
48+
print(f"brain={brain}")
49+
return _call([brain, "doctor"])
50+
if args.command == "mcp-command":
51+
print(f"{brain} serve --mcp")
52+
return 0
53+
if args.command == "doctor":
54+
cmd = [brain, "doctor"]
55+
if args.deep:
56+
cmd.append("--deep")
57+
return _call(cmd)
58+
if args.command in {"ask", "note"}:
59+
text = " ".join(getattr(args, "query", None) or getattr(args, "text", [])).strip()
60+
if not text:
61+
print(f"error: brain_bridge.py {args.command} requires text", file=sys.stderr)
62+
return 2
63+
return _call([brain, args.command, text])
64+
if args.command == "log":
65+
return _call([brain, "log"])
66+
return 2
67+
68+
69+
def _brain_bin() -> str | None:
70+
configured = os.environ.get("AGENTIC_STACK_BRAIN_BIN")
71+
if configured:
72+
return configured
73+
return shutil.which("brain")
74+
75+
76+
def _call(cmd: list[str]) -> int:
77+
try:
78+
return subprocess.run(cmd, cwd=Path.cwd(), check=False).returncode
79+
except FileNotFoundError as exc:
80+
print(f"error: {exc}", file=sys.stderr)
81+
return 2
82+
83+
84+
if __name__ == "__main__":
85+
raise SystemExit(main())

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project.
55
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.18.0] — 2026-05-10
9+
10+
Minor release. Adds first-class integration with the external Brain CLI/MCP
11+
memory system while keeping agentic-stack's project-local `.agent/` runtime
12+
independent and optional.
13+
14+
### Added
15+
- **Brain integration.** Adds `agentic-stack brain ...` and
16+
`.agent/tools/brain_bridge.py` so projects can use the external
17+
`codejunkie99/brain` CLI/MCP server as a git-backed long-term memory layer
18+
without vendoring the Rust workspace into agentic-stack.
19+
- **Brain seed skill.** Adds a `brain` skill that teaches host agents when to
20+
query or write Brain memory and how to avoid storing secrets.
21+
822
## [0.17.0] — 2026-05-10
923

1024
Minor release. Clears the open PR queue and ships new harness adapters, the

README.md

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,30 @@ metrics without training a model or sending telemetry.
2525
<img src="docs/diagram.svg" alt="agentic-stack architecture" width="880"/>
2626
</p>
2727

28-
### New in v0.17.0 — adapters, Mission Control, and lesson retraction
28+
### New in v0.18.0 — external Brain memory integration
29+
30+
Minor release. Adds an optional bridge to
31+
[`codejunkie99/brain`](https://github.com/codejunkie99/brain), the external
32+
git-backed long-term memory CLI/TUI/MCP server, without vendoring Brain's Rust
33+
workspace into agentic-stack.
34+
35+
- **`agentic-stack brain ...`.** Check Brain status, onboard a project, search
36+
global memory, write durable notes, run Brain doctor/TUI, or print the MCP
37+
stdio command from the normal agentic-stack CLI.
38+
- **Project bridge.** Installed `.agent/` projects now include
39+
`.agent/tools/brain_bridge.py`, so host agents can call Brain explicitly when
40+
a task needs cross-project recall.
41+
- **Brain seed skill.** A new `brain` skill teaches agents when to query or
42+
write Brain memory, and keeps secret handling explicit.
43+
44+
See [CHANGELOG.md](CHANGELOG.md) for the full list.
45+
46+
### v0.17.0 — adapters, Mission Control, and lesson retraction
2947

3048
Minor release. Clears the open PR queue and ships the combined production
3149
surface from Copilot CLI, Gemini, Mission Control, and semantic lesson
3250
retraction work.
3351

34-
- **New adapters.** GitHub Copilot CLI installs `AGENTS.md`,
35-
`.github/instructions/`, `.github/hooks/`, and `.github/skills/`; Google
36-
Gemini CLI installs `gemini.md` and a `.gemini/skills/` mirror.
37-
- **Mission Control beta.** Run `agentic-stack mission-control --port 8787`
38-
for a local web dashboard, or use `--snapshot` to render a static HTML
39-
report without opening a browser.
40-
- **Lesson retraction.** Run `.agent/tools/retract_lesson.py <lesson_id> --rationale "..."`
41-
to stop obsolete accepted lessons from guiding future recall while preserving
42-
append-only audit history.
43-
- **Test layout cleanup.** The validation suite now lives under `tests/` with
44-
pytest configuration, covering adapters, upgrades, Mission Control, and
45-
semantic retraction.
46-
47-
See [CHANGELOG.md](CHANGELOG.md) for the full list.
48-
4952
### v0.16.1 — getting-started refresh
5053

5154
Patch release. Ships the production-ready getting-started guide from PR #49
@@ -175,6 +178,7 @@ verb-style subcommands (works with both `install.sh` and `install.ps1`):
175178
```bash
176179
./install.sh dashboard # TUI dashboard: health, verify, memory, team, skills, instances
177180
./install.sh mission-control # beta local web dashboard; Ctrl-C turns it off
181+
./install.sh brain status # optional external Brain CLI integration
178182
./install.sh add cursor # add a second adapter (Claude Code + Cursor in same repo)
179183
./install.sh status # one-screen view: which adapters, brain stats
180184
./install.sh doctor # read-only audit; green / yellow / red per adapter
@@ -188,6 +192,32 @@ verb-style subcommands (works with both `install.sh` and `install.ps1`):
188192

189193
PowerShell uses the same verbs, for example `.\install.ps1 dashboard`.
190194

195+
### Optional: external Brain integration
196+
197+
[`codejunkie99/brain`](https://github.com/codejunkie99/brain) is the
198+
git-backed long-term memory binary and MCP server. agentic-stack now treats it
199+
as an optional external memory layer instead of vendoring its Rust workspace.
200+
201+
Install Brain first:
202+
203+
```bash
204+
brew install codejunkie99/tap/brain
205+
```
206+
207+
Then check or wire it from a project:
208+
209+
```bash
210+
agentic-stack brain status
211+
agentic-stack brain onboard --agents codex,cursor --yes
212+
agentic-stack brain ask "auth decisions"
213+
agentic-stack brain note "Use PKCE for local OAuth flows."
214+
agentic-stack brain mcp-command
215+
```
216+
217+
Installed `.agent/` projects also get `python3 .agent/tools/brain_bridge.py`
218+
and a `brain` seed skill so host agents can query or write Brain memory when a
219+
task needs cross-harness long-term recall.
220+
191221
Bare `./install.sh` (no arguments) opens a **multi-select wizard** on
192222
a fresh project — check every harness you actually use, hit enter,
193223
each one gets installed. The wizard auto-detects harnesses already on
@@ -389,6 +419,7 @@ The index is stored at `.agent/memory/.index/` and gitignored.
389419
├── show.py # colorful brain-state dashboard
390420
├── data_layer_export.py # local cross-harness dashboard/data export
391421
├── data_flywheel_export.py # approved runs -> traces/cards/evals/JSONL
422+
├── brain_bridge.py # bridge to external Brain CLI/MCP memory
392423
├── list_candidates.py
393424
├── graduate.py
394425
├── reject.py
@@ -417,6 +448,7 @@ harness_manager/ # v0.9.0 manifest-driven Python backend
417448
├── remove.py # safe uninstall with shared-file detection + ownership handoff
418449
├── dashboard_tui.py # project dashboard for health/verify/memory/team/skills/instances
419450
├── mission_control.py # beta local web dashboard entrypoint
451+
├── brain.py # optional external Brain CLI integration
420452
├── mission_control_collectors.py
421453
├── mission_control_render.py
422454
├── mission_control_server.py

docs/getting-started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ the project root:
8181
```bash
8282
agentic-stack dashboard # TUI dashboard: health, verify, memory, team, skills
8383
agentic-stack mission-control # beta local web dashboard; Ctrl-C turns it off
84+
agentic-stack brain status # optional external Brain CLI integration
8485
agentic-stack status # one-screen view: which adapters, brain stats
8586
agentic-stack doctor # read-only audit; green / yellow / red per adapter
8687
agentic-stack upgrade --dry-run # preview safe .agent infrastructure refresh
@@ -93,6 +94,7 @@ Source checkout users can run the same verbs through the clone:
9394
```bash
9495
./install.sh dashboard /path/to/your-project
9596
./install.sh mission-control /path/to/your-project
97+
./install.sh brain status
9698
./install.sh status /path/to/your-project
9799
./install.sh doctor /path/to/your-project
98100
./install.sh upgrade /path/to/your-project --dry-run

harness_manager/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
This package is the implementation backend for `./install.sh` and `./install.ps1`.
44
The user-facing surface is plain verbs: install, add, remove, doctor, status,
5-
dashboard, mission-control, manage, transfer, upgrade, and sync-manifest.
5+
dashboard, mission-control, brain, manage, transfer, upgrade, and sync-manifest.
66
The "harness_manager" name is internal only and never appears in CLI help, docs,
77
or error messages users see.
88
"""
9-
__version__ = "0.17.0"
9+
__version__ = "0.18.0"

0 commit comments

Comments
 (0)