Metadata-Version: 2.4
Name: shellbrain
Version: 0.1.61
Summary: Repo-scoped Shellbrain CLI with explicit evidence-backed writes.
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: SQLAlchemy<3.0,>=2.0
Requires-Dist: alembic<2.0,>=1.13
Requires-Dist: pydantic<3.0,>=2.7
Requires-Dist: psycopg[binary]<4.0,>=3.1
Requires-Dist: pgvector<1.0,>=0.3
Requires-Dist: sentence-transformers<4.0,>=3.0

<p align="center">
  <img src="https://raw.githubusercontent.com/cucupac/shellbrain/main/docs/assets/shellbrain_logo_badge.png" alt="ShellBrain logo" height="88">
</p>

<h3 align="center">ShellBrain</h3>

<p align="center">Long-term Memory for AI Agents.</p>

ShellBrain carries useful lessons from one agent task to the next. It preserves decision reasons, failed approaches, product direction, and preferences that the resulting code does not explain.

## Install

```bash
curl -L shellbrain.ai/install | bash
```

**Works for Codex, Claude Code, and Cursor.** The installer configures the runtime automatically. Repos register themselves on first use.

Requirements.
- macOS or Linux, Python 3.11+, Docker for the managed local Postgres+pgvector runtime.

### Upgrade for latest capabilities

```bash
shellbrain upgrade
```

You can also run `curl -L shellbrain.ai/upgrade | bash`.

---

## Recall in one command

<p align="center">
  <img src="docs/assets/shellbrain-recall-context-diagram.png" alt="ShellBrain recall uses vector search and BM25 to search your memories. An inner recall agent summarizes the search results." width="720">
</p>

---

## Architecture

ShellBrain stores evidence and two forms of reusable knowledge:

- **Episodic knowledge records evidence.** It stores prompts, agent steps, tool calls, and outputs from each session.
- **Empirical knowledge extracts concrete memories.** It organizes problems, solutions, failed tactics, facts, preferences, and changes in a semantic graph for **case-based reasoning**.
- **Conceptual knowledge abstracts reusable ideas.** Its concept graph connects claims, relations, and implementations to empirical knowledge.

Memories and concept claims link to supporting evidence. A concept can express a product principle without a duplicate memory. Current code remains the source of truth for implementation details.

---

## How Agents Use ShellBrain

### Recall

Working agents run `shellbrain recall` to get one compact brief for the current task.

Recall and automatic learning use the same evidence selector. It combines BM25, vector similarity, and graph links. Learning agents receive the selected records. The recall agent can summarize them.

Recall receives only the quoted query. Include the relevant task, failure, subsystem, or decision in the question.

```bash
shellbrain recall "What is ShellBrain, and how does it help a working coding agent?"
```

**Response format:**

```json
{
  "status": "ok",
  "data": {
    "brief": {
      "summary": "...",
      "constraints": ["..."],
      "known_traps": ["..."],
      "prior_cases": ["..."],
      "concept_orientation": ["..."],
      "anchors": ["`README.md`"],
      "conflicts": ["..."],
      "gaps": ["..."],
      "next_checks": ["..."]
    },
    "fallback_reason": null
  },
  "errors": []
}
```

Recall selects an evidence pack in code, then asks an inner agent to summarize it. Source attribution comes from the selected records. Provider failures return a brief directly from that same pack.

### Recall provider

For faster recall, [get an Inception API key](https://platform.inceptionlabs.ai/dashboard/api-keys), replace `PASTE_YOUR_KEY_HERE`, and run once:

```bash
mkdir -p ~/.shellbrain
printf '\nINCEPTION_API_KEY=%s\n' 'PASTE_YOUR_KEY_HERE' >> ~/.shellbrain/.env
chmod 600 ~/.shellbrain/.env
shellbrain admin recall provider inception
```

Shellbrain loads the saved key automatically. Switch back with `shellbrain admin recall provider codex` (the default), or choose `claude`.

---

## Repair

Run `shellbrain upgrade` to repair an existing installation. Setup and schema migrations run automatically.

---

## Docs

- [For Humans](https://shellbrain.ai/humans/): installation, upgrades, and first steps
- [For Agents](https://shellbrain.ai/agents/): agent workflow and memory rules
- [Technical Docs](https://deepwiki.com/cucupac/shellbrain): detailed documentation and code map
