Persistent memory layer for AI agents โ survives sessions, learns patterns, enables continuity
Project description
๐ง Cognex
Persistent memory layer for AI agents โ survives sessions, learns patterns, enables continuity.
Give your AI coding assistant long-term memory, decision tracking, and trust management.
Why Use It?
You: "Remember I prefer pytest over unittest"
Next session:
AI: "Got it โ I'll use pytest for your tests instead."
Your AI forgets everything between sessions. Cognex fixes that.
Features
| Feature | What It Does |
|---|---|
| ๐ง Persistent Memory | Remembers preferences, facts, patterns across sessions |
| ๐ Decision Ledger | Tracks choices made and their outcomes |
| ๐ก๏ธ Trust Engine | Learns which tools you approve vs deny |
| ๐ Teleportation | Export your brain, load it on another machine |
| ๐ Swarm Mode | Turn natural language into multi-agent plans |
Supported AI Tools
| Tool | Works? |
|---|---|
| Claude Code | โ |
| Claude Desktop | โ |
| OpenCode | โ |
| Cursor | โ |
| Codex | โ |
| Any MCP-compatible tool | โ |
Installation (Choose One)
Option 1: uvx (Recommended โ no install needed)
uvx cognex
Option 2: pipx (isolated environment)
pipx install cognex
Option 3: pip (system-wide install)
pip install cognex
Option 4: Install from this folder (development)
cd D:\COGNITIVE\cognitive-substrate
pip install -e .
Configuration by CLI Tool
OpenCode
Config location: %USERPROFILE%\.config\opencode\opencode.json
With uvx (no install):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cognex": {
"type": "local",
"command": ["uvx", "cognex"],
"enabled": true
}
}
}
With pipx:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cognex": {
"type": "local",
"command": ["pipx", "run", "cognex"],
"enabled": true
}
}
}
With pip (simplest):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cognex": {
"type": "local",
"command": ["cognex"],
"enabled": true
}
}
}
Claude Code / Claude Desktop
Config location (Windows): %APPDATA%\Claude\claude_desktop_config.json
Config location (Mac): ~/Library/Application Support/Claude/claude_desktop_config.json
With pip:
{
"mcpServers": {
"cognex": {
"command": "cognex"
}
}
}
With uvx:
{
"mcpServers": {
"cognex": {
"command": "uvx",
"args": ["cognex"]
}
}
}
Cursor
Config location (Windows): %USERPROFILE%\.cursor\mcp.json
Config location (Mac): ~/.cursor/mcp.json
With pip:
{
"mcpServers": {
"cognex": {
"command": "cognex"
}
}
}
VS Code (with MCP extension)
Create .vscode/mcp.json in your project:
{
"servers": {
"cognex": {
"command": "uvx",
"args": ["cognex"]
}
}
}
Codex
Add to your Codex config (~/.codex/config.json):
{
"mcpServers": {
"cognex": {
"command": "cognex"
}
}
}
Restart Your AI Tool
After adding the config, completely close and reopen your AI tool. You should see 18 new tools available.
The 18 Tools
๐๏ธ Session Management
| Tool | Description |
|---|---|
substrate_start_session |
Start a new work session |
substrate_end_session |
End session with summary/metrics |
substrate_process_transcript |
Extract memories from conversation |
substrate_report |
Get memory health report |
๐พ Memory
| Tool | Description |
|---|---|
memory_add |
Add a memory (fact, preference, decision, pattern) |
memory_search |
Search memories with filters |
memory_get_context |
Get relevant context for current work |
memory_decay |
Age memories (auto-cleanup old ones) |
๐ก๏ธ Trust Engine
| Tool | Description |
|---|---|
trust_check |
Check if tool needs approval |
trust_record |
Record approval/denial/violation |
trust_get |
Get trust score for a tool |
trust_summary |
Get trust overview |
๐ Decision Ledger
| Tool | Description |
|---|---|
ledger_record |
Record a decision made |
ledger_outcome |
Record what happened after |
ledger_find_similar |
Find similar past decisions |
๐ Teleportation
| Tool | Description |
|---|---|
teleport_create_bundle |
Export your brain to JSON |
teleport_rehydrate |
Import brain from another machine |
๐ Swarm
| Tool | Description |
|---|---|
swarm_compile_intent |
Turn "build me an API" into a multi-agent plan |
Example Usage
Remember a Preference
You: "I prefer using type hints everywhere"
AI: (calls memory_add)
โ Saved to your memory bank
Get Context Next Session
You: (start new session)
AI: (calls memory_get_context with "coding style")
โ Returns: "I prefer using type hints everywhere"
AI: "Got it โ I'll add type hints throughout."
Track a Decision
You: "FastAPI or Flask?"
AI: "FastAPI has better type safety."
AI: (calls ledger_record)
Later...
You: "Did that work out?"
AI: (calls ledger_outcome with success: true)
Tool Trust Check
AI wants to run: rm -rf /
AI: (calls trust_check)
โ {requires_approval: true, trust_level: 0.2}
AI asks: "Can I delete everything?"
Where Data is Stored
All data stays local on your machine in SQLite:
%USERPROFILE%\.cognex\
โโโ cognex.db
โโโ memories (your persistent memories)
โโโ sessions (session history)
โโโ trust_records (tool approval history)
โโโ decisions (decision ledger)
Troubleshooting
"command not found" or "cognex" not recognized
Fix: Make sure you installed it:
pip install cognex
Or use uvx in your config:
"command": ["uvx", "cognex"]
Tools not appearing
- Check the AI tool's developer console for errors
- Try restarting the AI tool completely
- Verify your JSON config is valid (use a JSON validator)
Development
# Run tests
cd D:\COGNITIVE\cognitive-substrate
python tests/test_mcp_server.py
# Run pytest
python -m pytest tests/ -v -k "not mcp_server"
# Run demo
python demo/run_demo.py
File Structure
D:\COGNITIVE\cognitive-substrate\
โโโ README.md โ You are here!
โโโ mcp.json โ MCP config ready to copy
โโโ pyproject.toml โ Package config (name: cognex)
โโโ demo/
โ โโโ run_demo.py โ Simple demo
โ โโโ run_full_demo.py โ Full workflow demo
โโโ src/
โ โโโ substrate/ โ Core memory system
โ โ โโโ substrate.py โ Main orchestrator
โ โ โโโ store.py โ SQLite storage
โ โ โโโ extractor.py โ Memory extraction
โ โ โโโ retriever.py โ Memory retrieval
โ โ โโโ ledger.py โ Decision tracking
โ โ โโโ trust.py โ Trust engine
โ โ โโโ teleport.py โ State export/import
โ โ โโโ swarm.py โ Multi-agent planning
โ โโโ substrate_mcp/ โ MCP server
โ โโโ server.py โ MCP server entry
โ โโโ tools/ โ 18 tool implementations
โโโ tests/
โโโ test_substrate.py โ Core tests
โโโ test_layers.py โ Layer tests
โโโ test_mcp_server.py โ Tool tests
License
MIT โ free to use, modify, and distribute.
Need Help?
- ๐ Source code:
D:\COGNITIVE\cognitive-substrate\src\ - ๐งช Run tests:
python tests/test_mcp_server.py - ๐ง Tool implementations:
src\substrate_mcp\tools\
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cognex-0.1.0.tar.gz.
File metadata
- Download URL: cognex-0.1.0.tar.gz
- Upload date:
- Size: 40.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2436f228a9b8198ffa54a8a30e5fbddb7a797c9987b861065f5233c5322f4e3a
|
|
| MD5 |
9e9ee2c74b7756bc8293ca519c579125
|
|
| BLAKE2b-256 |
33c892eedaa1f6a4e7b7687ae60849d2a7bf80a1d77fae6a3a85e16da4b9dc6e
|
Provenance
The following attestation bundles were made for cognex-0.1.0.tar.gz:
Publisher:
publish.yml on Gaurav7974/cognex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cognex-0.1.0.tar.gz -
Subject digest:
2436f228a9b8198ffa54a8a30e5fbddb7a797c9987b861065f5233c5322f4e3a - Sigstore transparency entry: 1235376096
- Sigstore integration time:
-
Permalink:
Gaurav7974/cognex@cb208746b0ef2e0ac6fee931ba2d2bfe23a658db -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Gaurav7974
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cb208746b0ef2e0ac6fee931ba2d2bfe23a658db -
Trigger Event:
push
-
Statement type:
File details
Details for the file cognex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cognex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a469cec9c83552a8177f13f29ef7f72d86fd1889676cc1cf82c69beea773c660
|
|
| MD5 |
bb8d20a7826e35ee57fee5c7c108fac7
|
|
| BLAKE2b-256 |
cc9cfaa6f662d51f0a4dd1fd40df525e05a5fd7cb04b7bacf3a5f86f712b7b5c
|
Provenance
The following attestation bundles were made for cognex-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Gaurav7974/cognex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cognex-0.1.0-py3-none-any.whl -
Subject digest:
a469cec9c83552a8177f13f29ef7f72d86fd1889676cc1cf82c69beea773c660 - Sigstore transparency entry: 1235376173
- Sigstore integration time:
-
Permalink:
Gaurav7974/cognex@cb208746b0ef2e0ac6fee931ba2d2bfe23a658db -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Gaurav7974
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cb208746b0ef2e0ac6fee931ba2d2bfe23a658db -
Trigger Event:
push
-
Statement type: