Metadata-Version: 2.4
Name: brain-framework
Version: 35.0.0
Summary: Brain Framework: from information to informed actions.
Keywords: ai,ai-agents,agent-memory,agent-skills,agents-md,context-engineering,json,json-schema,knowledge-graph,knowledge-management,local-first,personal-knowledge-management,python,second-brain
Author: Médéric Hurier
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Indexing
Classifier: Typing :: Typed
Requires-Dist: jsonschema-rs>=0.63.0,<1
Requires-Dist: markdown-it-py>=3.0.0,<5
Requires-Dist: pyyaml>=6.0.3,<7
Requires-Python: >=3.12
Project-URL: Changelog, https://fmind.github.io/brain-framework/changelog/
Project-URL: Documentation, https://fmind.github.io/brain-framework/
Project-URL: Issues, https://github.com/fmind/brain-framework/issues
Project-URL: Repository, https://github.com/fmind/brain-framework
Project-URL: Security, https://github.com/fmind/brain-framework/security/policy
Description-Content-Type: text/markdown

<p align="center">
  <img
    src="https://raw.githubusercontent.com/fmind/brain-framework/main/docs/assets/brain-framework.svg"
    alt="Brain Framework logo"
    width="128"
  />
</p>

<h1 align="center">Brain Framework</h1>

<p align="center">
  <strong>From information to informed actions.</strong>
</p>

<p align="center">
  <a href="https://github.com/fmind/brain-framework/actions/workflows/ci.yml"><img src="https://github.com/fmind/brain-framework/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
  <a href="https://pypi.org/project/brain-framework/"><img src="https://img.shields.io/pypi/v/brain-framework?color=174EA6" alt="PyPI" /></a>
  <a href="https://pypi.org/project/brain-framework/"><img src="https://img.shields.io/pypi/pyversions/brain-framework" alt="Python" /></a>
  <a href="https://github.com/fmind/brain-framework/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-174EA6" alt="License: MIT" /></a>
</p>

**Brain Framework** turns a regular Git folder into a living second brain that you own forever. Combine plain Markdown memory that humans and coding agents can search offline with continuous loops that keep sensors, listeners, and always-on agents running around the clock.

- **Plain files, zero lock-in**: Markdown, YAML, and JSONL with three dependencies, versioned in Git, and zero built-in LLMs.
- **Shared memory, backed by evidence**: Edit Markdown in any editor, query offline from any coding agent, and flag stale decisions when linked facts change.
- **Continuous loops for always-on agents**: Supervise scheduled sensors, live channel daemons, and event-driven agents together with `bf watch` and per-loop secret allowlists.

<p align="center">
  <img
    src="https://raw.githubusercontent.com/fmind/brain-framework/main/docs/assets/demo.gif"
    alt="Brain Framework terminal demo: ranked search, backlinks, staleness review, and live bf watch supervision"
    width="100%"
  />
</p>

## Quickstart

Requires Linux or macOS and [uv](https://docs.astral.sh/uv/getting-started/installation/) (Python 3.12+). No model API key, database server, or cloud account is required.

Install the CLI and initialize a brain folder:

```bash
uv tool install brain-framework
bf init ~/brain
cd ~/brain
```

Ingest a source record, write a decision note that cites it, and build the local search index:

```bash
bf ingest workspace <<'EOF'
{
  "id": "brief",
  "title": "Website brief",
  "type": "doc",
  "text": "Start with one clear product page before signup.",
  "created": "2026-11-10T09:00:00Z",
  "updated": "2026-11-10T09:00:00Z"
}
EOF

cat > projects/launch.md <<'EOF'
---
type: project
status: active
created: 2026-11-12
updated: 2026-11-15
description: Launch one focused product page.
---

# Launch site

## Decision {#decision}

Ship one product page first ([brief](workspace:brief){rel=cites}).
EOF

bf build
```

Search offline to see your decision rank ahead of the raw brief. Then update the brief and let `bf review` catch the stale decision automatically:

```bash
bf query "product page" --format text

bf ingest workspace <<'EOF'
{
  "id": "brief",
  "title": "Website brief",
  "type": "doc",
  "text": "Add a pricing table before signup.",
  "created": "2026-11-10T09:00:00Z",
  "updated": "2026-11-20T14:00:00Z"
}
EOF
bf review --format text
```

Output:

```text
Query (fts5): 2 result(s) for 'product page'

  projects/launch.md#decision  Launch site
    Launch site Decision Ship one product page first (brief).
  workspace:brief  Website brief
    Start with one clear product page before signup.

Review: brain  [STALE (1)]
  stale=1  open_tasks=0

  REF                 REASONS                 DETAIL
  projects/launch.md  newer_evidence          newer: workspace:brief
```

Next, follow [Getting started](https://fmind.github.io/brain-framework/getting-started/), wire continuous loops in [Loops](https://fmind.github.io/brain-framework/loops/), or explore the [offline example brain](https://github.com/fmind/brain-framework/blob/main/examples/brain/README.md).

## How it works

<a href="https://raw.githubusercontent.com/fmind/brain-framework/main/docs/assets/brain-loop.svg">
  <img
    src="https://raw.githubusercontent.com/fmind/brain-framework/main/docs/assets/brain-loop.svg"
    alt="Perceive, normalize, connect, act, and learn loop connecting your tools, your brain folder, and your routines and agents"
    width="100%"
  />
</a>

A brain is one portable directory where perception, memory, and action feed each other:

- **Perceive**: Small [sensors](https://fmind.github.io/brain-framework/loops/) collect records from your tools into flat JSONL files, while always-on daemons listen to live channels such as chat or webhooks.
- **Remember**: Humans and agents curate Markdown [notes](https://fmind.github.io/brain-framework/authoring/) linked to raw evidence. A read-only, disposable offline [search](https://fmind.github.io/brain-framework/retrieval/) index finds answers in milliseconds and flags notes when linked facts change.
- **Act and learn**: Routines, event-driven agents, and interactive coding harnesses read that context, act through your existing CLIs or APIs, and write outcomes back to the brain.

Memory and continuous loops sit on the same level inside one `bf.yaml` and 3x3 layout, and either side works on its own:

- **Memory**: Plain Markdown notes with instant offline search, section reads, staleness checks, and agent recall.
- **Loops**: Scheduled tool feeds, live `daemon` listeners, event-driven agents, and 24/7 `bf watch` supervision.

```text
my-brain/
├── bf.yaml         # Declarative config for notes, search, and loops
├── concepts/       # Durable knowledge, standards, and conventions
├── projects/       # Ongoing initiatives and decisions
├── actions/        # Scoped requests, deliverables, and attachments
├── sensors/        # Scheduled scripts collecting records from your tools
├── routines/       # Maintenance jobs and always-on stream daemons
└── agents/         # Scheduled and event-driven coding-harness tasks
```

See the full layout and runtime folders (`memories/`, `logs/`, `.bf/`) in the [reference](https://fmind.github.io/brain-framework/reference/#brain-layout).

## Works with your AI coding harness

Brain Framework works with Claude Code, Codex, GitHub Copilot, Antigravity, Gemini CLI, OpenCode, and any terminal agent without running an MCP server.

- **Inside a brain**: Agents read the folder's `AGENTS.md`, check health and stale notes, edit Markdown directly, and verify changes with `bf build` and `bf check`.
- **From any repository**: Export `BF_BRAIN` to point to your brain folder and install the optional [`/bf` skill](https://github.com/fmind/brain-framework/blob/main/skills/bf/SKILL.md) with `npx skills add fmind/brain-framework --skill bf`.

A typical read-only lookup from another repository:

```bash
bf status --format text                     # Orient: health, counts, and attention items
bf query "product page" --kind note         # Search curated notes first
bf read "projects/launch.md#decision"       # Load one cited section without extra noise
bf query --links-to "workspace:brief"       # Follow backlinks to every citing note
bf review --format text                     # Spot stale decisions and open tasks
```

## Run continuous loops and always-on agents

Declare plain shell or Python scripts in `bf.yaml` to keep your brain updated and run always-on agents without an external orchestrator. `bf watch` supervises scheduled sensors, passive channel daemons, delayed timers, and event-driven agents together, forwarding only the secrets each loop allowlists:

```yaml
version: 20
name: my-brain
concurrency:
  default: 4
  interactive: 2
loops:
  github-issues:
    description: Pull GitHub issues every 30 minutes.
    run: [python3, sensors/github-issues.py, owner/repo]
    env_from: [GH_TOKEN]
    ingest: upsert
    when: 30m
  chat:
    description: Stream incoming messages from a live channel.
    run: [python3, routines/chat.py, listen]
    emit: loop.message
    mode: daemon
  triage:
    description: Run hourly checks and reply immediately to live messages.
    run: [python3, agents/triage.py]
    pool: interactive
    timeout: 15m
    env_from: [ANTHROPIC_API_KEY]
    when:
      - every: 1h
      - event:
          kind: loop.message
          source: chat
```

Passive `mode: daemon` listeners stay running cheaply in plain code, while agents wake on a schedule or matching event, run your preferred coding harness, and write outcomes back to the brain.

- **Preview or run once**: Inspect resolved commands and secrets with `bf run triage --dry-run`, or run a single cycle with `bf run github-issues`.
- **Supervise around the clock**: Run `bf watch` interactively for a live terminal dashboard, or under `systemd` or `launchd` for 24/7 structured JSONL logging.
- **Control live loops**: Mute flaky jobs with `bf pause` and attach a read-only live view from another terminal with `bf status --watch`.

See [Loops](https://fmind.github.io/brain-framework/loops/) for sensor contracts, event predicates, and concurrency pools, [Operations](https://fmind.github.io/brain-framework/operations/) for 24/7 supervision, and [Security](https://fmind.github.io/brain-framework/security/) for secret allowlists and limits.

## How it compares

| Approach                       | Storage and ownership                | Search and agent interface                             | Automation and trust                                            |
| :----------------------------- | :----------------------------------- | :----------------------------------------------------- | :-------------------------------------------------------------- |
| **Brain Framework**            | Plain Git Markdown + flat JSONL      | Read-only CLI, ranked offline search, `rg`/`jq`/DuckDB | Continuous `bf watch` loops with per-loop secret allowlists     |
| **Plain Markdown / Obsidian**  | Local Markdown files                 | Filename or grep search; no staleness checks           | Manual upkeep or UI plugins; no structured feeds                |
| **Hosted / MCP memory**        | Opaque or remote database            | Always-on MCP schemas and model-mediated recall        | Extra services and API keys; hard to audit in Git               |
| **Generic vector RAG**         | Chunked embeddings in a vector index | Similarity over opaque chunks                          | Needs embedding pipelines; weak provenance and backlinks        |
| **Monolithic agent platforms** | App-owned database or plugin state   | Bundled LLM runtime and platform-specific SDKs         | Broad host or token permissions; hard to swap harnesses or edit |

## When not to use

- You want turnkey SaaS connectors, built-in LLM synthesis, or an MCP server instead of running your own CLI scripts and coding harness.
- You need semantic vector search, multimodal blob storage, or multi-user concurrent web editing across millions of records.
- You run primarily on native Windows without WSL (Brain Framework targets Linux and macOS POSIX confinement).

## More

[Documentation](https://fmind.github.io/brain-framework/) | [CLI reference](https://fmind.github.io/brain-framework/reference/) | [Example brain](https://github.com/fmind/brain-framework/blob/main/examples/brain/README.md) | [Issues](https://github.com/fmind/brain-framework/issues) | [Security](https://github.com/fmind/brain-framework/security/policy) | [License (MIT)](https://github.com/fmind/brain-framework/blob/main/LICENSE)
