Skip to main content

Unified second brain for AI agents โ€” 5-tier memory, HRR reasoning, 14 MCP tools, Zettelkasten linking, memory evolution

Project description

๐Ÿง  Eling

Unified second brain for AI agents โ€” 5-tier memory, HRR reasoning, 14 MCP tools, Zettelkasten linking, memory evolution, spec-kit verification, conditional verify-on-stop

"Eling" (Javanese): to remember, to be conscious, to be aware

Python 3.10+ License: MIT MCP PyPI


โœจ What is Eling?

Eling is a unified second brain for AI agents. It merges 5 memory tiers into one MCP server โ€” no external databases, no cloud services needed for local operation.

๐Ÿง  Tier 5: NOTION   โ€” online brain, human-readable (optional)
๐Ÿ“š Tier 4: KB       โ€” FTS5 knowledge corpus
๐Ÿ•ธ๏ธ Tier 3: CODE     โ€” codegraph symbol intelligence
๐Ÿ’Ž Tier 2: FACTS    โ€” SQLite + HRR + BM25 hybrid with trust scoring
๐Ÿ“Œ Tier 1: BUILTIN   โ€” Hermes MEMORY.md / USER.md

All accessible via 14 MCP tools from a single stdio server:

Tool Purpose
eling_remember Store content โ€” auto-routes to facts (short) or KB (long)
eling_recall Cross-layer search with RRF fusion (BM25 + trigram + porter)
eling_reason Compositional query tying multiple entities together
eling_probe Get all facts about an entity
eling_reflect Promote a high-trust fact to Notion as a permanent page
eling_sync Bidirectional sync between memory layers
eling_stats Show per-layer statistics
eling_think Synthesis + gap analysis across layers
eling_export Full brain export as JSON or Markdown
eling_verify Query/record verification status with optional spec-kit check
eling_verify_spec Run spec-kit conformance verification against project specs
eling_link_stats Zettelkasten link graph statistics
eling_linked_facts Get facts linked to a given fact_id
eling_evolve Trigger memory evolution (merge near-duplicates)

๐Ÿš€ Quick Start

pip install eling

# Run MCP server (stdio โ€” plug into any MCP host)
python3 -m eling.mcp_server

# Or use the CLI
python3 -m eling --help

๐Ÿ”Œ Hermes Integration

Eling plugs into Hermes Agent at 3 levels:

1. MCP Server โ€” add to ~/.hermes/config.yaml:

mcp_servers:
  eling:
    command: python3
    args: ["-m", "eling.mcp_server"]
    enabled: true

2. Memory Provider โ€” sets default brain for remember/recall:

memory:
  provider: eling

3. Plugin โ€” registers eling_remember + eling_recall as quick tools:

plugins:
  enabled:
    - eling
  eling:
    home: /root/.eling

๐Ÿ“‹ CLI Commands

python3 -m eling remember   "I learned that..."
python3 -m eling recall     "what did I learn about X"
python3 -m eling probe      "X"
python3 -m eling reason     ["X", "Y"]
python3 -m eling reflect    1                 # promote fact_id 1 to Notion
python3 -m eling verify                        # query verification status
python3 -m eling verify-spec                   # run spec-kit conformance
python3 -m eling link-stats                    # Zettelkasten link graph stats
python3 -m eling linked-facts 1                # facts linked to fact_id 1
python3 -m eling evolve                        # merge near-duplicate facts
python3 -m eling stats
python3 -m eling export     --format markdown
python3 -m eling sync       --direction push   # facts โ†’ Notion

๐ŸŒ Notion Setup (Tier 5)

Optional โ€” skip this if you only need local memory.

  1. Create a Notion integration at https://www.notion.so/my-integrations

    • Give it a name (e.g. "Eling Brain")
    • Copy the Internal Integration Secret (starts with ntn_)
  2. Share a parent page with your integration

    • Open the page you want as your second brain root
    • Click Share โ†’ Invite โ†’ select your integration
    • Copy the page URL and extract the page ID (the UUID in the URL, e.g. 38f7b66e-c7e0-813f-85b0-d37cef59c1f7)
  3. Set environment variables:

export NOTION_API_KEY="ntn_..."
export NOTION_PARENT_PAGE_ID="38f7b66e-c7e0-813f-85b0-d37cef59c1f7"

Note-taking behavior

Once configured, eling auto-creates a ๐Ÿ“‹ Task Logs child page under your parent on first use:

๐Ÿ“‹ Hermes Vault (parent page โ€” your configured root)
  โ”œโ”€โ”€ ๐Ÿ“‹ Task Logs        โ† auto-created by eling
  โ”‚   โ”œโ”€โ”€ ๐Ÿ’ก Eling test โ† child pages from eling_reflect / remember(layer="notion")
  โ”‚   โ””โ”€โ”€ ๐Ÿ’ก Another note
  โ”œโ”€โ”€ ๐Ÿ”‘ API Keys...
  โ””โ”€โ”€ ...

Two ways to add notes to Notion:

Method Usage Route
brain.reflect(fact_id) / eling_reflect Promote a high-trust fact to Notion โ†’ auto-routes by category
brain.remember("text", layer="notion") / eling_remember with layer=notion Store content directly as a Notion page โ†’ auto-routes by category

Auto-routing by category

Content is automatically detected and routed to the right child page:

Category Triggers Child page
project_summary "project done/complete/selesai", "deploy success", "summary completion" ๐ŸŽฏ Project Summaries
credential "api_key", "password", "secret", "token", "credential" ๐Ÿ”‘ Credentials
address "alamat", "address", "domicile", "tinggal di" ๐Ÿ“ Addresses
config "config", "setup", "setting", "environment" โš™๏ธ Configurations
(uncategorised) Everything else ๐Ÿ“‹ Task Logs

Example:

# Auto-routes to ๐ŸŽฏ Project Summaries
b.remember("Project done, deployed to production", layer="notion")
# Auto-routes to ๐Ÿ”‘ Credentials
b.remember("DATABASE_URL = postgres://...", layer="notion")
# Auto-routes to ๐Ÿ“‹ Task Logs (no pattern match)
b.remember("General note", layer="notion")

All child pages under these category pages are full Notion pages โ€” you can edit, move, share, or reference them normally.

Or pass them explicitly in code:

from eling.brain import Brain
b = Brain(
    notion_api_key="ntn_...",
    notion_parent_id="38f7b66e-..."
)
result = b.reflect(fact_id=1)
print(result)  # {"page_id": "...", "promoted": True}

# Or store directly as a note
result = b.remember("Quick note for Notion", layer="notion")
print(result)  # {"layer": "notion", "page_id": "...", ...}

Note: eling_reflect and remember(layer="notion") check availability at call time and return a clear error if any config is missing โ€” no silent failures.

๐Ÿ›ก๏ธ Verify-on-Stop (Conditional)

Eling provides verify-on-stop nudges for AI agents that lack built-in verification (e.g., OpenCode, OpenClaw, Cursor, Windsurf). When running under Hermes, this feature automatically skips โ€” because Hermes already has its own agent/verification_stop.py.

How it works

  1. Auto-detection โ€” Eling detects the host agent from the MCP client's initialize handshake (clientInfo.name), which is more reliable than environment variable heuristics (prevents false Hermes detection when OpenCode runs under Hermes)
  2. File edit tracking โ€” When code files are edited via hooks or MCP tools, eling records them in a verification ledger
  3. Spec-kit conformance โ€” If the project has spec-kit artifacts (specs/*/spec.md), eling checks whether code changes cover each spec requirement and includes gaps in the nudge
  4. Verification nudge โ€” If code was edited but no passing tests/verification was recorded, eling produces a [System: ...] nudge message
  5. Recording โ€” Agents can call eling_verify MCP tool to record verification results (passed, failed, skipped)

Spec-kit Verification

Projects using spec-kit (Spec-Driven Development) get automatic spec conformance checking:

  • Eling detects specs/<feature>/spec.md, plan.md, and tasks.md artifacts
  • Requirements are extracted from spec markdown and matched against code files
  • The eling_verify_spec tool returns coverage stats + uncovered requirements
  • The standard eling_verify tool includes spec-kit results when spec_check=true
  • Uncovered requirements are listed in the verification nudge for the agent to address

Usage via MCP

// Query current status
{ "method": "tools/call", "params": { "name": "eling_verify", "arguments": {} } }

// Record a passing verification
{ "method": "tools/call", "params": {
    "name": "eling_verify",
    "arguments": { "status": "passed", "command": "pytest", "output": "364 passed" }
} }

// Run spec-kit conformance check
{ "method": "tools/call", "params": {
    "name": "eling_verify_spec",
    "arguments": { "changed_files": ["src/main.py"] }
} }

// Combine both: verify + spec-kit
{ "method": "tools/call", "params": {
    "name": "eling_verify",
    "arguments": { "spec_check": true }
} }

Config

Key Default Env Description
verify_on_stop true ELING_VERIFY_ON_STOP Enable nudges for non-Hermes agents
verify_on_stop_max_attempts 2 ELING_VERIFY_MAX_ATTEMPTS Max nudges per session
adapter hermes ELING_ADAPTER Force adapter type
plugins:
  eling:
    adapter: auto       # auto-detect from env
    verify_on_stop: true

๐Ÿ—๏ธ Architecture

eling/
โ”œโ”€โ”€ mcp_server.py     โ€” JSON-RPC stdio server (14 tools)
โ”œโ”€โ”€ brain.py          โ€” Orchestrator: routing + RRF fusion + sync + linking
โ”œโ”€โ”€ config.py         โ€” Layered config: env โ†’ json โ†’ defaults
โ”œโ”€โ”€ hooks.py          โ€” 15 lifecycle hooks + HookRegistry + evolution
โ”œโ”€โ”€ verify_on_stop.py โ€” Verification ledger + nudge builder + spec-kit wiring
โ”œโ”€โ”€ spec_kit.py       โ€” Spec-kit artifact parser + coverage analyzer
โ”œโ”€โ”€ privacy.py        โ€” PII/secret stripping (19 patterns)
โ”œโ”€โ”€ compress.py       โ€” SHA-256 dedup + length compression
โ”œโ”€โ”€ cli.py            โ€” CLI client for all 14 operations
โ””โ”€โ”€ layers/
    โ”œโ”€โ”€ builtin.py    โ€” Tier 1: Hermes MEMORY.md / USER.md loader
    โ”œโ”€โ”€ facts.py      โ€” Tier 2: SQLite + HRR + BM25 + trust + linking + evolution
    โ”œโ”€โ”€ hrr.py        โ€” Holographic Reduced Representations (optional numpy)
    โ”œโ”€โ”€ code.py       โ€” Tier 3: CodeLayer wrapper
    โ”œโ”€โ”€ code_index.py โ€” Pure-Python AST+regex code indexer
    โ”œโ”€โ”€ kb.py         โ€” Tier 4: FTS5 + porter + trigram + RRF
    โ””โ”€โ”€ notion.py     โ€” Tier 5: httpx Notion API client (lazy import)

โšก Performance

  • Lazy imports โ€” numpy and httpx are imported only when their layer is first used, not at module load time
  • import eling takes ~1.3s (was ~4.5s with module-level imports on Alpine)
  • Pure-Python fallback when numpy unavailable (BM25-only retrieval still works)

๐Ÿ“– Documentation

๐Ÿค Credits

  • HRR phase encoding + facts layer โ€” adapted from holographic plugin by dusterbloom (Hermes PR #2351, MIT)
  • Spec-kit integration โ€” spec-driven development artifacts (spec-kit by GitHub, MIT)

๐Ÿ“œ License

MIT ยฉ 2026 PatrickNoFilter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eling-0.4.0.tar.gz (105.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eling-0.4.0-py3-none-any.whl (83.1 kB view details)

Uploaded Python 3

File details

Details for the file eling-0.4.0.tar.gz.

File metadata

  • Download URL: eling-0.4.0.tar.gz
  • Upload date:
  • Size: 105.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eling-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9bbda6910d83e2a0d1bc1cff1446d734aa6138ac4aa825956b5cb06441121c18
MD5 f1f3226e2700935b87f26f4ee9d026c2
BLAKE2b-256 a9b6ef35de332c5681316b04e5eaf4ccebc456b5e9e3ec72ecebe915b9141a63

See more details on using hashes here.

File details

Details for the file eling-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: eling-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 83.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eling-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f0f56d44b5b2e1d649cc841536172bee8c81f0bae9d0e264785572f7b7c0a01
MD5 a2604c570f6029fdb770f054eb1e1d3b
BLAKE2b-256 2b3b2889be97dc9148a0a4acc82d42423964083d4e8895e3eea849fd98f915c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page