brain-core-mcp 0.2.2__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.
- brain_core_mcp-0.2.2/.editorconfig +15 -0
- brain_core_mcp-0.2.2/.github/ISSUE_TEMPLATE/bug_report.md +24 -0
- brain_core_mcp-0.2.2/.github/ISSUE_TEMPLATE/feature_request.md +15 -0
- brain_core_mcp-0.2.2/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- brain_core_mcp-0.2.2/.github/workflows/release.yml +60 -0
- brain_core_mcp-0.2.2/.github/workflows/test.yml +40 -0
- brain_core_mcp-0.2.2/.gitignore +58 -0
- brain_core_mcp-0.2.2/.pre-commit-config.yaml +18 -0
- brain_core_mcp-0.2.2/.python-version +1 -0
- brain_core_mcp-0.2.2/CHANGELOG.md +34 -0
- brain_core_mcp-0.2.2/CONTRIBUTING.md +31 -0
- brain_core_mcp-0.2.2/LICENSE +21 -0
- brain_core_mcp-0.2.2/PKG-INFO +239 -0
- brain_core_mcp-0.2.2/README.md +196 -0
- brain_core_mcp-0.2.2/docs/MILESTONES.md +24 -0
- brain_core_mcp-0.2.2/docs/RELEASING.md +34 -0
- brain_core_mcp-0.2.2/docs/SPEC_v0.2.md +73 -0
- brain_core_mcp-0.2.2/docs/THREAT_MODEL.md +61 -0
- brain_core_mcp-0.2.2/docs/VAULT_SCHEMA.md +28 -0
- brain_core_mcp-0.2.2/docs/img/install.svg +33 -0
- brain_core_mcp-0.2.2/docs/img/session.svg +30 -0
- brain_core_mcp-0.2.2/install.sh +94 -0
- brain_core_mcp-0.2.2/pyproject.toml +104 -0
- brain_core_mcp-0.2.2/src/brain_core/__init__.py +13 -0
- brain_core_mcp-0.2.2/src/brain_core/agent.py +423 -0
- brain_core_mcp-0.2.2/src/brain_core/cli/__init__.py +1 -0
- brain_core_mcp-0.2.2/src/brain_core/cli/doctor.py +66 -0
- brain_core_mcp-0.2.2/src/brain_core/cli/export.py +120 -0
- brain_core_mcp-0.2.2/src/brain_core/cli/init.py +80 -0
- brain_core_mcp-0.2.2/src/brain_core/cli/main.py +297 -0
- brain_core_mcp-0.2.2/src/brain_core/config.py +173 -0
- brain_core_mcp-0.2.2/src/brain_core/cron.py +403 -0
- brain_core_mcp-0.2.2/src/brain_core/decisions/__init__.py +37 -0
- brain_core_mcp-0.2.2/src/brain_core/decisions/classifier.py +235 -0
- brain_core_mcp-0.2.2/src/brain_core/distill.py +269 -0
- brain_core_mcp-0.2.2/src/brain_core/installer.py +214 -0
- brain_core_mcp-0.2.2/src/brain_core/mcp/__init__.py +8 -0
- brain_core_mcp-0.2.2/src/brain_core/mcp/server.py +123 -0
- brain_core_mcp-0.2.2/src/brain_core/mcp/tools.py +343 -0
- brain_core_mcp-0.2.2/src/brain_core/memory/__init__.py +26 -0
- brain_core_mcp-0.2.2/src/brain_core/memory/episodic.py +105 -0
- brain_core_mcp-0.2.2/src/brain_core/memory/hsam.py +105 -0
- brain_core_mcp-0.2.2/src/brain_core/memory/structured.py +207 -0
- brain_core_mcp-0.2.2/src/brain_core/py.typed +0 -0
- brain_core_mcp-0.2.2/src/brain_core/recall.py +169 -0
- brain_core_mcp-0.2.2/src/brain_core/reflection/__init__.py +38 -0
- brain_core_mcp-0.2.2/src/brain_core/reflection/session.py +233 -0
- brain_core_mcp-0.2.2/src/brain_core/remember.py +129 -0
- brain_core_mcp-0.2.2/src/brain_core/session.py +269 -0
- brain_core_mcp-0.2.2/src/brain_core/status.py +126 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/__init__.py +11 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/db.py +97 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/migrations/001_initial.sql +105 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/migrations/002_relations.sql +15 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/migrations/__init__.py +5 -0
- brain_core_mcp-0.2.2/src/brain_core/storage/migrator.py +103 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/__init__.py +26 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/base.py +56 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/fakes.py +39 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/graph.py +110 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/hindsight.py +167 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/sqlite.py +68 -0
- brain_core_mcp-0.2.2/src/brain_core/stores/vault.py +428 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/__init__.py +0 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/hooks/block-dangerous-bash.sh +77 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/rules/01-identity.md +26 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/rules/02-doctrine.md +35 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/rules/03-authority.md +40 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/rules/04-memory.md +45 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/rules/05-system.md +24 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/settings.json +10 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/skills/brain-check/SKILL.md +21 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/skills/distill/SKILL.md +55 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.claude/skills/session-end/SKILL.md +26 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/.mcp.json +6 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/CLAUDE.md +15 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/_gitignore +10 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/brain.yaml +23 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/data/.gitkeep +0 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/corrections.md +10 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/daily_brief.md +3 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/decisions_log.md +14 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/executive_state.md +24 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/facts.md +11 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/goals/mission_queue.md +12 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/inbox_staged.md +10 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/knowledge/_index.md +2 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/knowledge/_log.md +3 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/last_standalone_session.md +11 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/patterns.md +12 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/procedures/README.md +3 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/raw/.gitkeep +0 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/session_critique.md +17 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/sessions/.gitkeep +0 -0
- brain_core_mcp-0.2.2/src/brain_core/templates/agent/vault/user_profile.md +13 -0
- brain_core_mcp-0.2.2/tests/__init__.py +0 -0
- brain_core_mcp-0.2.2/tests/conftest.py +26 -0
- brain_core_mcp-0.2.2/tests/eval/__init__.py +0 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/recall.yaml +23 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/corrections.md +23 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/decisions_log.md +25 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/facts.md +31 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/knowledge/_index.md +3 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/knowledge/llm-wiki-pattern.md +11 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/patterns.md +14 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/raw/2026-11-02-llm-wiki.md +8 -0
- brain_core_mcp-0.2.2/tests/eval/fixture/vault/sessions/2026-11-01.md +14 -0
- brain_core_mcp-0.2.2/tests/eval/run_recall.py +77 -0
- brain_core_mcp-0.2.2/tests/eval/run_write.py +88 -0
- brain_core_mcp-0.2.2/tests/eval/test_fixture_eval.py +32 -0
- brain_core_mcp-0.2.2/tests/eval/write_tasks.yaml +37 -0
- brain_core_mcp-0.2.2/tests/integration/__init__.py +0 -0
- brain_core_mcp-0.2.2/tests/integration/test_agent.py +268 -0
- brain_core_mcp-0.2.2/tests/integration/test_decisions.py +205 -0
- brain_core_mcp-0.2.2/tests/integration/test_mcp_server.py +61 -0
- brain_core_mcp-0.2.2/tests/integration/test_mcp_tools.py +185 -0
- brain_core_mcp-0.2.2/tests/integration/test_memory_episodic.py +85 -0
- brain_core_mcp-0.2.2/tests/integration/test_memory_hsam.py +81 -0
- brain_core_mcp-0.2.2/tests/integration/test_memory_structured.py +169 -0
- brain_core_mcp-0.2.2/tests/integration/test_reflection.py +240 -0
- brain_core_mcp-0.2.2/tests/integration/test_storage.py +160 -0
- brain_core_mcp-0.2.2/tests/integration/test_stores_live.py +62 -0
- brain_core_mcp-0.2.2/tests/test_smoke.py +14 -0
- brain_core_mcp-0.2.2/tests/unit/__init__.py +0 -0
- brain_core_mcp-0.2.2/tests/unit/test_cli.py +189 -0
- brain_core_mcp-0.2.2/tests/unit/test_config.py +123 -0
- brain_core_mcp-0.2.2/tests/unit/test_cron.py +140 -0
- brain_core_mcp-0.2.2/tests/unit/test_distill.py +97 -0
- brain_core_mcp-0.2.2/tests/unit/test_hindsight_graph_stores.py +91 -0
- brain_core_mcp-0.2.2/tests/unit/test_installer.py +88 -0
- brain_core_mcp-0.2.2/tests/unit/test_migrator.py +28 -0
- brain_core_mcp-0.2.2/tests/unit/test_recall.py +92 -0
- brain_core_mcp-0.2.2/tests/unit/test_remember.py +95 -0
- brain_core_mcp-0.2.2/tests/unit/test_session.py +117 -0
- brain_core_mcp-0.2.2/tests/unit/test_sqlite_store.py +29 -0
- brain_core_mcp-0.2.2/tests/unit/test_status.py +55 -0
- brain_core_mcp-0.2.2/tests/unit/test_vault_store.py +211 -0
- brain_core_mcp-0.2.2/uv.lock +1095 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something brain-core did wrong
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**What happened**
|
|
8
|
+
|
|
9
|
+
**What you expected**
|
|
10
|
+
|
|
11
|
+
**How to reproduce**
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
brain version
|
|
15
|
+
brain doctor ~/Agents/NAME
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Paste the output of both, and the tool reply if an MCP call was involved (`layers`, `stores`, `note`).
|
|
19
|
+
|
|
20
|
+
**Environment**
|
|
21
|
+
|
|
22
|
+
- macOS version / Linux distro:
|
|
23
|
+
- Claude Code version (`claude --version`):
|
|
24
|
+
- Hindsight: `brain hindsight status`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Something the brain should do
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**The situation** (what you were doing when you wished for it)
|
|
8
|
+
|
|
9
|
+
**What the agent should have done**
|
|
10
|
+
|
|
11
|
+
**Which tool it belongs in** (`brain_session` / `brain_recall` / `brain_remember` / `brain_distill` / `brain_status` / `brain daily`)
|
|
12
|
+
|
|
13
|
+
brain-core keeps five tools. If this needs a sixth, say why it cannot live in one of the five.
|
|
14
|
+
|
|
15
|
+
**Context cost** (if it touches the template pack: rules are always loaded, skills load on use, hooks and scripts are free)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
**What breaks without this change**
|
|
2
|
+
|
|
3
|
+
**What changed**
|
|
4
|
+
|
|
5
|
+
**Checks**
|
|
6
|
+
|
|
7
|
+
- [ ] `uv run pytest` green, including `tests/eval`
|
|
8
|
+
- [ ] `ruff check`, `ruff format --check`, `mypy` clean
|
|
9
|
+
- [ ] if recall or remember changed: an eval row that fails without this PR
|
|
10
|
+
- [ ] if the template pack changed: token cost stated here
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# Tag v* → build sdist+wheel → publish to PyPI (trusted publishing, no token) → GitHub Release.
|
|
4
|
+
# One-time setup on PyPI: add a "pending publisher" for xy-claude/brain-core, workflow
|
|
5
|
+
# release.yml, environment pypi. See docs/RELEASING.md.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["v*"]
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write # create the GitHub Release
|
|
13
|
+
id-token: write # OIDC for PyPI trusted publishing
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: astral-sh/setup-uv@v4
|
|
21
|
+
- run: uv python install 3.12
|
|
22
|
+
- run: uv sync --all-extras --all-groups
|
|
23
|
+
- name: Tests must pass before anything ships
|
|
24
|
+
run: uv run pytest -q
|
|
25
|
+
- name: Tag must match pyproject version
|
|
26
|
+
run: |
|
|
27
|
+
v="$(uv run brain version)"
|
|
28
|
+
[ "v$v" = "${GITHUB_REF_NAME}" ] || { echo "tag ${GITHUB_REF_NAME} != pyproject $v"; exit 1; }
|
|
29
|
+
- run: uv build
|
|
30
|
+
- uses: actions/upload-artifact@v4
|
|
31
|
+
with: {name: dist, path: dist/}
|
|
32
|
+
|
|
33
|
+
pypi:
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment: pypi
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/download-artifact@v4
|
|
39
|
+
with: {name: dist, path: dist/}
|
|
40
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
41
|
+
|
|
42
|
+
github-release:
|
|
43
|
+
needs: build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: actions/download-artifact@v4
|
|
48
|
+
with: {name: dist, path: dist/}
|
|
49
|
+
- name: Release notes from CHANGELOG
|
|
50
|
+
run: |
|
|
51
|
+
awk -v tag="${GITHUB_REF_NAME#v}" '
|
|
52
|
+
$0 ~ "^## \\[" tag "\\]" {p=1; next}
|
|
53
|
+
p && /^## \[/ {exit}
|
|
54
|
+
p {print}
|
|
55
|
+
' CHANGELOG.md > notes.md
|
|
56
|
+
[ -s notes.md ] || echo "See CHANGELOG.md" > notes.md
|
|
57
|
+
- uses: softprops/action-gh-release@v2
|
|
58
|
+
with:
|
|
59
|
+
body_path: notes.md
|
|
60
|
+
files: dist/*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v4
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Python
|
|
25
|
+
run: uv python install 3.12
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --all-extras
|
|
29
|
+
|
|
30
|
+
- name: Lint (ruff check)
|
|
31
|
+
run: uv run ruff check src tests
|
|
32
|
+
|
|
33
|
+
- name: Format check (ruff format)
|
|
34
|
+
run: uv run ruff format --check src tests
|
|
35
|
+
|
|
36
|
+
- name: Type check (mypy --strict)
|
|
37
|
+
run: uv run mypy
|
|
38
|
+
|
|
39
|
+
- name: Tests (pytest)
|
|
40
|
+
run: uv run pytest --cov
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
|
|
8
|
+
# Virtual environments
|
|
9
|
+
.venv/
|
|
10
|
+
venv/
|
|
11
|
+
env/
|
|
12
|
+
|
|
13
|
+
# Packaging / build
|
|
14
|
+
build/
|
|
15
|
+
dist/
|
|
16
|
+
*.egg-info/
|
|
17
|
+
*.egg
|
|
18
|
+
.eggs/
|
|
19
|
+
wheels/
|
|
20
|
+
pip-wheel-metadata/
|
|
21
|
+
|
|
22
|
+
# Testing / coverage
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
.coverage.*
|
|
26
|
+
htmlcov/
|
|
27
|
+
coverage.xml
|
|
28
|
+
.tox/
|
|
29
|
+
.hypothesis/
|
|
30
|
+
|
|
31
|
+
# Type checkers / linters
|
|
32
|
+
.mypy_cache/
|
|
33
|
+
.ruff_cache/
|
|
34
|
+
|
|
35
|
+
# uv
|
|
36
|
+
.uv-cache/
|
|
37
|
+
|
|
38
|
+
# Runtime artifacts (agents consuming this package store their DBs/logs;
|
|
39
|
+
# ignore any that leak into this repo during development)
|
|
40
|
+
*.db
|
|
41
|
+
*.db-shm
|
|
42
|
+
*.db-wal
|
|
43
|
+
*.jsonl
|
|
44
|
+
*.log
|
|
45
|
+
|
|
46
|
+
# Editors / OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
.idea/
|
|
49
|
+
.vscode/
|
|
50
|
+
*.swp
|
|
51
|
+
*~
|
|
52
|
+
|
|
53
|
+
# Env
|
|
54
|
+
.env
|
|
55
|
+
.env.local
|
|
56
|
+
|
|
57
|
+
# Machine-specific eval configs
|
|
58
|
+
local/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.8.4
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
10
|
+
rev: v5.0.0
|
|
11
|
+
hooks:
|
|
12
|
+
- id: check-yaml
|
|
13
|
+
- id: check-toml
|
|
14
|
+
- id: check-merge-conflict
|
|
15
|
+
- id: end-of-file-fixer
|
|
16
|
+
- id: trailing-whitespace
|
|
17
|
+
- id: check-added-large-files
|
|
18
|
+
args: [--maxkb=500]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes. Format: [Keep a Changelog](https://keepachangelog.com). Versions follow SemVer; the tag `vX.Y.Z` must equal `pyproject.toml`.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.2.2] - 2026-11-02
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- PyPI distribution name is `brain-core-mcp`; PyPI rejected `brain-core` as too similar to an existing project. Command `brain` and package `brain_core` unchanged.
|
|
11
|
+
|
|
12
|
+
## [0.2.1] - 2026-11-02
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Linux support: `install.sh` runs on Linux (uv, systemd user unit for Hindsight, user crontab for `brain daily` / `brain weekly`).
|
|
16
|
+
- Release pipeline: tag `v*` builds, tests, publishes to PyPI by trusted publishing, and creates a GitHub Release with these notes.
|
|
17
|
+
- `CHANGELOG.md`, `docs/RELEASING.md`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- `install.sh` installs from PyPI first and falls back to the git tag.
|
|
21
|
+
|
|
22
|
+
## [0.2.0] - 2026-11-02
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- The five `brain_*` MCP tools: `brain_recall`, `brain_remember`, `brain_session`, `brain_distill`, `brain_status`.
|
|
26
|
+
- Store adapters: markdown vault, SQLite + FTS5, Hindsight (MCP over HTTP), entity graph as a SQLite relations table.
|
|
27
|
+
- `brain init` template pack: CLAUDE.md, five generic rule files, three skills, bash guard hook, `.mcp.json`, vault skeleton (3,014 always-loaded tokens); `--user`, `--profile`.
|
|
28
|
+
- `brain daily`, `brain weekly`, `brain cron install` (launchd).
|
|
29
|
+
- `install.sh` one-line installer for macOS; `brain hindsight install`; `brain doctor` on `brain_status`.
|
|
30
|
+
- Eval suite: 20-task fixture vault in CI, write scenarios; live recall evals on the author's vault at 100%.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
- The 14 one-tool-per-function MCP endpoints from v0.1 (still available as the Python API).
|
|
34
|
+
- Kuzu as the graph backend; `brain graph import` loads a legacy dump.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for looking. brain-core is small on purpose; the best pull request is the one that removes a line.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/xy-claude/brain-core && cd brain-core
|
|
9
|
+
uv sync --all-extras --all-groups
|
|
10
|
+
uv run pytest # 200+ tests, includes the fixture eval, no network
|
|
11
|
+
uv run ruff check src tests && uv run ruff format --check src tests && uv run mypy
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
CI runs exactly those four commands. If they pass locally they pass there.
|
|
15
|
+
|
|
16
|
+
## Ground rules
|
|
17
|
+
|
|
18
|
+
- **Five tools stay five.** A new capability goes inside an existing `brain_*` tool or into `brain daily`, not into a sixth tool. The point of the project is an agent that never has to choose between 30 endpoints.
|
|
19
|
+
- **Context is a budget.** Anything added to the template pack (`src/brain_core/templates/agent/`) must state its token cost in the PR. Rules are always loaded; skills load on use; scripts and hooks cost nothing. Prefer the cheaper one.
|
|
20
|
+
- **The vault is readable.** Markdown layouts are documented in `docs/VAULT_SCHEMA.md`. A write that a human cannot read in Obsidian is a bug.
|
|
21
|
+
- **Evals before claims.** A change to recall or remember comes with an eval row in `tests/eval/` that fails without it.
|
|
22
|
+
- **No secrets, anywhere.** gitleaks runs in CI and the vault refuses token-shaped text. If you need a key for a test, it comes from the environment and the test skips when it is absent.
|
|
23
|
+
- **Failed layers are reported, never swallowed.** Every store call returns a status; a `try/except: pass` will not be merged.
|
|
24
|
+
|
|
25
|
+
## Pull requests
|
|
26
|
+
|
|
27
|
+
One change per PR. Subject line under 72 characters in the imperative. Describe what breaks without the change. No attribution trailers.
|
|
28
|
+
|
|
29
|
+
## Reporting a bug
|
|
30
|
+
|
|
31
|
+
Use the bug template. `brain doctor` output and `brain version` save a round trip.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xy-claude
|
|
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,239 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: brain-core-mcp
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Cognitive primitives for AI agents — memory, decisions, reflection.
|
|
5
|
+
Project-URL: Repository, https://github.com/xy-claude/brain-core
|
|
6
|
+
Author: xy-claude
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 xy-claude
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Keywords: agents,ai,llm,mcp,memory
|
|
30
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
36
|
+
Requires-Python: >=3.12
|
|
37
|
+
Requires-Dist: pydantic>=2.9
|
|
38
|
+
Requires-Dist: pyyaml>=6.0
|
|
39
|
+
Requires-Dist: typer>=0.15
|
|
40
|
+
Provides-Extra: mcp
|
|
41
|
+
Requires-Dist: mcp>=1.0; extra == 'mcp'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# brain-core
|
|
45
|
+
|
|
46
|
+
**A memory for your Claude Code agent that survives the session.** One local MCP server, five tools, a markdown vault you can read, an eval that proves recall. Installs with one command.
|
|
47
|
+
|
|
48
|
+
[](https://github.com/xy-claude/brain-core/actions/workflows/test.yml)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](pyproject.toml)
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
curl -fsSL https://raw.githubusercontent.com/xy-claude/brain-core/main/install.sh | bash -s -- --agent Atlas --user Alex
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## The problem
|
|
59
|
+
|
|
60
|
+
Every session with a coding agent starts from zero. You explain the project again, the decision you made last week again, the thing it got wrong on Tuesday again. Memory add-ons exist, but they put your notes in someone's cloud, expose 30 tools the agent cannot choose between, and nobody shows you an eval.
|
|
61
|
+
|
|
62
|
+
brain-core is the opposite: local, five tools, markdown files you own, and a test suite that reports hit rates.
|
|
63
|
+
|
|
64
|
+
## What you get
|
|
65
|
+
|
|
66
|
+
```mermaid
|
|
67
|
+
flowchart LR
|
|
68
|
+
CC[Claude Code] -->|MCP, 5 tools| B[brain serve]
|
|
69
|
+
B --> V[(vault/ markdown)]
|
|
70
|
+
B --> S[(brain.db SQLite + FTS)]
|
|
71
|
+
B --> H[(Hindsight vector memory)]
|
|
72
|
+
B --> G[(relations table)]
|
|
73
|
+
CRON[brain daily / weekly] --> V
|
|
74
|
+
CRON --> H
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Tool | One call does |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `brain_session('start')` | the whole start block: daily brief, executive state, mental models, a recall per mission, inbox count, and a flag if the last session crashed |
|
|
80
|
+
| `brain_recall(query)` | one query across every store, deduplicated, ranked by relevance and recency, capped at 6k tokens |
|
|
81
|
+
| `brain_remember(text, kind)` | writes vault → SQLite → Hindsight → graph and reports each layer. Near-duplicates are skipped; a changed value gets a `⚠ Fact changed` banner and the old line stays |
|
|
82
|
+
| `brain_distill(source)` | captures a URL, GitHub repo, YouTube video, PDF, file or pasted text into an immutable `raw/` folder for the agent to compile |
|
|
83
|
+
| `brain_session('end')` | drains the queue, closes the day's session file, rewrites state and critique, writes the clean-close marker |
|
|
84
|
+
|
|
85
|
+
Plus `brain_status()` for health in one call, and two cron jobs that write the next morning's brief, back up memory, and archive old sessions.
|
|
86
|
+
|
|
87
|
+
## Install
|
|
88
|
+
|
|
89
|
+
### macOS, one line
|
|
90
|
+
|
|
91
|
+
<img src="docs/img/install.svg" alt="install.sh transcript" width="820">
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
curl -fsSL https://raw.githubusercontent.com/xy-claude/brain-core/main/install.sh | bash -s -- --agent Atlas --user Alex
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
What it does, in order (re-running skips what is already there):
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
== 1/8 Xcode command line tools present
|
|
101
|
+
== 2/8 Homebrew present
|
|
102
|
+
== 3/8 uv, gh, gitleaks, node, Claude Code
|
|
103
|
+
== 4/8 brain-core (v0.2.0) installed with uv tool
|
|
104
|
+
== 5/8 Agent Atlas at ~/Agents/Atlas 31 files written
|
|
105
|
+
== 6/8 Hindsight (required store) service: healthy
|
|
106
|
+
== 7/8 Cron daily 06:07, weekly Sun 07:13
|
|
107
|
+
== 8/8 Doctor Brain: OK
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then, once: `export ANTHROPIC_API_KEY=...` (Hindsight uses it to reason over memories), and `claude` to sign in to Claude Code.
|
|
111
|
+
|
|
112
|
+
| Flag | Meaning |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `--agent NAME` | the agent's name (required) |
|
|
115
|
+
| `--user Alex` | how the agent addresses you |
|
|
116
|
+
| `--dir PATH` | where the agent lives, default `~/Agents/NAME` |
|
|
117
|
+
| `--provider` | `anthropic` (default), `openai`, or `claude-code` (uses your Claude Code login; personal use only) |
|
|
118
|
+
| `--profile DIR` | a folder copied over the generic rules last, for your own doctrine |
|
|
119
|
+
| `--dashboard` | the Hindsight web UI on http://localhost:9999 |
|
|
120
|
+
| `--ref v0.2.2` | pin a git tag instead of the PyPI release |
|
|
121
|
+
|
|
122
|
+
### Linux
|
|
123
|
+
|
|
124
|
+
The same one line. On Linux it installs uv, Claude Code via npm when node is present, Hindsight as a systemd user service, and the two jobs in your user crontab.
|
|
125
|
+
|
|
126
|
+
### Manual, any platform
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
uv tool install brain-core-mcp # or: uv tool install git+https://github.com/xy-claude/brain-core@v0.2.2
|
|
130
|
+
brain init Atlas --path ~/Agents/Atlas --user Alex
|
|
131
|
+
brain hindsight install # launchd on macOS, systemd --user on Linux
|
|
132
|
+
brain cron install ~/Agents/Atlas
|
|
133
|
+
brain doctor ~/Agents/Atlas
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## First session
|
|
137
|
+
|
|
138
|
+
<img src="docs/img/session.svg" alt="first session transcript" width="820">
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
cd ~/Agents/Atlas && claude
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The agent's `CLAUDE.md` tells it to open with `brain_session('start')`. What comes back:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"session_id": "s-20261102-a1b2c3",
|
|
149
|
+
"brief": "# Daily Brief — 2026-11-02 ...",
|
|
150
|
+
"executive_state": "## Primary Objective ... ## Top Missions ... ## Pending Decisions ...",
|
|
151
|
+
"mental_models": {"active-priorities": "..."},
|
|
152
|
+
"missions": {"M-001 first mission": [ ...3 recall hits... ]},
|
|
153
|
+
"inbox": 0,
|
|
154
|
+
"recovery": null
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Say something worth keeping and the agent calls `brain_remember`:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{"status": "written", "layers": {"vault": {"status": "written", "detail": "facts.md › System"},
|
|
162
|
+
"sqlite": {"status": "written"},
|
|
163
|
+
"hindsight": {"status": "written", "detail": "op 162bdbaa"}}}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Say "thanks, we're done" and it runs `brain_session('end')`. Tomorrow at 06:07 `brain daily` writes the next brief from what you did today.
|
|
167
|
+
|
|
168
|
+
## What is in the agent folder
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
~/Agents/Atlas
|
|
172
|
+
├── CLAUDE.md identity and the five-tool protocol (3k tokens always loaded)
|
|
173
|
+
├── .claude/
|
|
174
|
+
│ ├── rules/ 01-identity 02-doctrine 03-authority 04-memory 05-system
|
|
175
|
+
│ ├── skills/ distill, session-end, brain-check
|
|
176
|
+
│ └── hooks/ block-dangerous-bash.sh (rm -rf, force-push, curl|sh …)
|
|
177
|
+
├── .mcp.json brain serve . + Hindsight
|
|
178
|
+
├── brain.yaml stores, session files, cron schedule
|
|
179
|
+
├── vault/ facts.md patterns.md decisions_log.md corrections.md
|
|
180
|
+
│ ├── sessions/ one file per day (HSAM)
|
|
181
|
+
│ ├── knowledge/ raw/ the LLM-wiki: immutable sources, compiled pages
|
|
182
|
+
│ └── executive_state.md objective, missions, pending decisions
|
|
183
|
+
└── data/brain.db SQLite + FTS5 + relations
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Everything is markdown or SQLite. Open the vault in Obsidian, grep it, commit it, delete a line. The agent will not mind.
|
|
187
|
+
|
|
188
|
+
## Does it work?
|
|
189
|
+
|
|
190
|
+
The eval is part of the test suite and runs in CI.
|
|
191
|
+
|
|
192
|
+
| Set | Hits |
|
|
193
|
+
|---|---|
|
|
194
|
+
| 20 recall tasks on a synthetic fixture vault (CI) | 20 / 20 |
|
|
195
|
+
| 20 tune + 10 held-out recall tasks on the author's real vault, 7 months of sessions | 20 / 20 and 10 / 10 |
|
|
196
|
+
| 11 write scenarios: dedup, value-change banner, relation routing, secret refusal | 11 / 11 |
|
|
197
|
+
|
|
198
|
+
Recall takes about 1.7 s per query; Hindsight is the floor. A full start block is about 4 s and under 6k tokens.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python tests/eval/run_recall.py --config ~/Agents/Atlas/brain.yaml # your own vault
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## How memory is organised
|
|
205
|
+
|
|
206
|
+
| Kind | Lives in | Written as |
|
|
207
|
+
|---|---|---|
|
|
208
|
+
| fact | `vault/facts.md` under `## Domain` | `- text (date)` |
|
|
209
|
+
| pattern | `vault/patterns.md` | `- **title** — text (date)` |
|
|
210
|
+
| decision | `vault/decisions_log.md` | `## date — title` + Decision / Reason / Classification / Confidence |
|
|
211
|
+
| correction | `vault/corrections.md` | `### [date] title` + Error / Correction / Implied rule / Theme |
|
|
212
|
+
| note | `vault/sessions/YYYY-MM-DD.md` | a bullet under an HSAM section |
|
|
213
|
+
| relation | `data/brain.db` | subject —[predicate]→ object |
|
|
214
|
+
| raw | `vault/raw/` | immutable source with sha256; the agent compiles `vault/knowledge/` |
|
|
215
|
+
|
|
216
|
+
Rules: idempotent by content hash, append-only, nothing deleted, secrets refused before any store sees them. Details in [`docs/VAULT_SCHEMA.md`](docs/VAULT_SCHEMA.md).
|
|
217
|
+
|
|
218
|
+
## Requirements
|
|
219
|
+
|
|
220
|
+
- macOS or Linux for the installer; the library and MCP run anywhere Python 3.12 does
|
|
221
|
+
- [Hindsight](https://github.com/vectorize-io/hindsight) (MIT) as the vector store, installed for you. Postgres is embedded; embeddings run on CPU
|
|
222
|
+
- an LLM key for Hindsight's reasoning, or a Claude Code login for personal use
|
|
223
|
+
|
|
224
|
+
On PyPI the package is `brain-core-mcp` (the plain name collides with an unrelated project); the command is still `brain` and the import is still `brain_core`.
|
|
225
|
+
|
|
226
|
+
## Roadmap
|
|
227
|
+
|
|
228
|
+
- SQLite-only mode for a first run without Hindsight
|
|
229
|
+
- an `import` for existing notes folders
|
|
230
|
+
|
|
231
|
+
Shipped milestones: [`docs/MILESTONES.md`](docs/MILESTONES.md). Design: [`docs/SPEC_v0.2.md`](docs/SPEC_v0.2.md). Threat model for a memory that reads untrusted text: [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md).
|
|
232
|
+
|
|
233
|
+
## Contributing
|
|
234
|
+
|
|
235
|
+
Issues and pull requests welcome. `uv sync --all-extras --all-groups`, then `ruff check`, `mypy`, `pytest`. See [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
MIT.
|