cortex-mcp 2.8.0 → 3.0.0
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.
- package/CHANGELOG.md +305 -58
- package/README.md +394 -227
- package/dist/cli/setup.js +58 -60
- package/dist/cli/setup.js.map +1 -1
- package/dist/config/config.js +2 -2
- package/dist/config/config.js.map +1 -1
- package/dist/db/database.d.ts +8 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/database.js +35 -54
- package/dist/db/database.js.map +1 -1
- package/dist/db/event-log.d.ts +4 -0
- package/dist/db/event-log.d.ts.map +1 -1
- package/dist/db/event-log.js +14 -10
- package/dist/db/event-log.js.map +1 -1
- package/dist/db/memory-store.d.ts +30 -3
- package/dist/db/memory-store.d.ts.map +1 -1
- package/dist/db/memory-store.js +153 -55
- package/dist/db/memory-store.js.map +1 -1
- package/dist/embedding-worker.js +1 -1
- package/dist/embedding-worker.js.map +1 -1
- package/dist/hooks/git-capture.js +3 -3
- package/dist/hooks/git-hooks.js +5 -2
- package/dist/mcp-stdio.js +70 -15
- package/dist/mcp-stdio.js.map +1 -1
- package/dist/memory/access-pattern-tracker.d.ts +51 -0
- package/dist/memory/access-pattern-tracker.d.ts.map +1 -0
- package/dist/memory/access-pattern-tracker.js +92 -0
- package/dist/memory/access-pattern-tracker.js.map +1 -0
- package/dist/memory/anticipation-engine.d.ts.map +1 -1
- package/dist/memory/anticipation-engine.js +18 -10
- package/dist/memory/anticipation-engine.js.map +1 -1
- package/dist/memory/auto-learner.d.ts.map +1 -1
- package/dist/memory/auto-learner.js +192 -45
- package/dist/memory/auto-learner.js.map +1 -1
- package/dist/memory/completion-resolver.d.ts +38 -0
- package/dist/memory/completion-resolver.d.ts.map +1 -0
- package/dist/memory/completion-resolver.js +127 -0
- package/dist/memory/completion-resolver.js.map +1 -0
- package/dist/memory/confidence-decay.d.ts.map +1 -1
- package/dist/memory/confidence-decay.js +13 -9
- package/dist/memory/confidence-decay.js.map +1 -1
- package/dist/memory/convention-detector.d.ts +11 -0
- package/dist/memory/convention-detector.d.ts.map +1 -0
- package/dist/memory/convention-detector.js +294 -0
- package/dist/memory/convention-detector.js.map +1 -0
- package/dist/memory/correction-detector.d.ts +33 -0
- package/dist/memory/correction-detector.d.ts.map +1 -0
- package/dist/memory/correction-detector.js +129 -0
- package/dist/memory/correction-detector.js.map +1 -0
- package/dist/memory/cross-memory-linker.d.ts +18 -0
- package/dist/memory/cross-memory-linker.d.ts.map +1 -0
- package/dist/memory/cross-memory-linker.js +115 -0
- package/dist/memory/cross-memory-linker.js.map +1 -0
- package/dist/memory/daily-diary.d.ts +30 -0
- package/dist/memory/daily-diary.d.ts.map +1 -0
- package/dist/memory/daily-diary.js +159 -0
- package/dist/memory/daily-diary.js.map +1 -0
- package/dist/memory/embedding-cache.d.ts +32 -0
- package/dist/memory/embedding-cache.d.ts.map +1 -0
- package/dist/memory/embedding-cache.js +76 -0
- package/dist/memory/embedding-cache.js.map +1 -0
- package/dist/memory/embedding-manager.d.ts.map +1 -1
- package/dist/memory/embedding-manager.js +6 -4
- package/dist/memory/embedding-manager.js.map +1 -1
- package/dist/memory/error-learner.d.ts +26 -0
- package/dist/memory/error-learner.d.ts.map +1 -0
- package/dist/memory/error-learner.js +145 -0
- package/dist/memory/error-learner.js.map +1 -0
- package/dist/memory/export-import.js +2 -2
- package/dist/memory/export-import.js.map +1 -1
- package/dist/memory/file-relationships.d.ts +47 -0
- package/dist/memory/file-relationships.d.ts.map +1 -0
- package/dist/memory/file-relationships.js +130 -0
- package/dist/memory/file-relationships.js.map +1 -0
- package/dist/memory/git-memory.d.ts.map +1 -1
- package/dist/memory/git-memory.js +20 -26
- package/dist/memory/git-memory.js.map +1 -1
- package/dist/memory/impact-analyzer.d.ts +16 -0
- package/dist/memory/impact-analyzer.d.ts.map +1 -0
- package/dist/memory/impact-analyzer.js +189 -0
- package/dist/memory/impact-analyzer.js.map +1 -0
- package/dist/memory/instructions-generator.d.ts +30 -0
- package/dist/memory/instructions-generator.d.ts.map +1 -0
- package/dist/memory/instructions-generator.js +117 -0
- package/dist/memory/instructions-generator.js.map +1 -0
- package/dist/memory/learning-rate.js +8 -7
- package/dist/memory/learning-rate.js.map +1 -1
- package/dist/memory/llm-enhancer.d.ts +2 -14
- package/dist/memory/llm-enhancer.d.ts.map +1 -1
- package/dist/memory/llm-enhancer.js +66 -46
- package/dist/memory/llm-enhancer.js.map +1 -1
- package/dist/memory/memory-cache.d.ts.map +1 -1
- package/dist/memory/memory-cache.js +10 -0
- package/dist/memory/memory-cache.js.map +1 -1
- package/dist/memory/memory-consolidator.d.ts.map +1 -1
- package/dist/memory/memory-consolidator.js +20 -14
- package/dist/memory/memory-consolidator.js.map +1 -1
- package/dist/memory/memory-decay.d.ts.map +1 -1
- package/dist/memory/memory-decay.js +82 -52
- package/dist/memory/memory-decay.js.map +1 -1
- package/dist/memory/memory-export-md.d.ts +12 -0
- package/dist/memory/memory-export-md.d.ts.map +1 -0
- package/dist/memory/memory-export-md.js +188 -0
- package/dist/memory/memory-export-md.js.map +1 -0
- package/dist/memory/memory-quality.d.ts +1 -1
- package/dist/memory/memory-quality.d.ts.map +1 -1
- package/dist/memory/memory-quality.js +13 -27
- package/dist/memory/memory-quality.js.map +1 -1
- package/dist/memory/memory-ranker.d.ts.map +1 -1
- package/dist/memory/memory-ranker.js +12 -3
- package/dist/memory/memory-ranker.js.map +1 -1
- package/dist/memory/meta-memory.js +3 -3
- package/dist/memory/meta-memory.js.map +1 -1
- package/dist/memory/mmr-reranker.d.ts +39 -0
- package/dist/memory/mmr-reranker.d.ts.map +1 -0
- package/dist/memory/mmr-reranker.js +115 -0
- package/dist/memory/mmr-reranker.js.map +1 -0
- package/dist/memory/pre-flight.d.ts +24 -0
- package/dist/memory/pre-flight.d.ts.map +1 -0
- package/dist/memory/pre-flight.js +121 -0
- package/dist/memory/pre-flight.js.map +1 -0
- package/dist/memory/preference-learner.d.ts +28 -0
- package/dist/memory/preference-learner.d.ts.map +1 -0
- package/dist/memory/preference-learner.js +144 -0
- package/dist/memory/preference-learner.js.map +1 -0
- package/dist/memory/query-expansion.d.ts +28 -0
- package/dist/memory/query-expansion.d.ts.map +1 -0
- package/dist/memory/query-expansion.js +140 -0
- package/dist/memory/query-expansion.js.map +1 -0
- package/dist/memory/regression-guard.d.ts +35 -0
- package/dist/memory/regression-guard.d.ts.map +1 -0
- package/dist/memory/regression-guard.js +90 -0
- package/dist/memory/regression-guard.js.map +1 -0
- package/dist/memory/resume-work.d.ts +37 -0
- package/dist/memory/resume-work.d.ts.map +1 -0
- package/dist/memory/resume-work.js +141 -0
- package/dist/memory/resume-work.js.map +1 -0
- package/dist/memory/session-tracker.d.ts +2 -0
- package/dist/memory/session-tracker.d.ts.map +1 -1
- package/dist/memory/session-tracker.js +26 -8
- package/dist/memory/session-tracker.js.map +1 -1
- package/dist/memory/soul-manager.d.ts +30 -0
- package/dist/memory/soul-manager.d.ts.map +1 -0
- package/dist/memory/soul-manager.js +171 -0
- package/dist/memory/soul-manager.js.map +1 -0
- package/dist/memory/success-tracker.d.ts +33 -0
- package/dist/memory/success-tracker.d.ts.map +1 -0
- package/dist/memory/success-tracker.js +75 -0
- package/dist/memory/success-tracker.js.map +1 -0
- package/dist/memory/temporal-engine.d.ts.map +1 -1
- package/dist/memory/temporal-engine.js +9 -13
- package/dist/memory/temporal-engine.js.map +1 -1
- package/dist/memory/tool-recommender.d.ts +29 -0
- package/dist/memory/tool-recommender.d.ts.map +1 -0
- package/dist/memory/tool-recommender.js +117 -0
- package/dist/memory/tool-recommender.js.map +1 -0
- package/dist/memory/usage-stats.d.ts +98 -0
- package/dist/memory/usage-stats.d.ts.map +1 -0
- package/dist/memory/usage-stats.js +345 -0
- package/dist/memory/usage-stats.js.map +1 -0
- package/dist/retrieval/hybrid-retriever.d.ts +0 -2
- package/dist/retrieval/hybrid-retriever.d.ts.map +1 -1
- package/dist/retrieval/hybrid-retriever.js +3 -13
- package/dist/retrieval/hybrid-retriever.js.map +1 -1
- package/dist/scanners/architecture-graph.js +2 -2
- package/dist/scanners/architecture-graph.js.map +1 -1
- package/dist/scanners/code-verifier.d.ts +1 -0
- package/dist/scanners/code-verifier.d.ts.map +1 -1
- package/dist/scanners/code-verifier.js +14 -14
- package/dist/scanners/code-verifier.js.map +1 -1
- package/dist/scanners/context-builder.d.ts.map +1 -1
- package/dist/scanners/context-builder.js +33 -45
- package/dist/scanners/context-builder.js.map +1 -1
- package/dist/scanners/export-map.js +2 -2
- package/dist/scanners/export-map.js.map +1 -1
- package/dist/scanners/project-scanner.js +2 -2
- package/dist/scanners/project-scanner.js.map +1 -1
- package/dist/security/encryption.js +1 -1
- package/dist/security/encryption.js.map +1 -1
- package/dist/security/feature-gate.d.ts.map +1 -1
- package/dist/security/feature-gate.js +62 -20
- package/dist/security/feature-gate.js.map +1 -1
- package/dist/security/license.js +282 -35
- package/dist/security/license.js.map +1 -1
- package/dist/security/rate-limiter.d.ts +4 -3
- package/dist/security/rate-limiter.d.ts.map +1 -1
- package/dist/security/rate-limiter.js +11 -29
- package/dist/security/rate-limiter.js.map +1 -1
- package/dist/server/dashboard.js +166 -327
- package/dist/server/dashboard.js.map +1 -1
- package/dist/server/mcp-handler.d.ts.map +1 -1
- package/dist/server/mcp-handler.js +991 -1019
- package/dist/server/mcp-handler.js.map +1 -1
- package/dist/utils/extract-tags.d.ts +16 -0
- package/dist/utils/extract-tags.d.ts.map +1 -0
- package/dist/utils/extract-tags.js +40 -0
- package/dist/utils/extract-tags.js.map +1 -0
- package/package.json +18 -8
- package/dist/core/event-bus.d.ts +0 -19
- package/dist/core/event-bus.d.ts.map +0 -1
- package/dist/core/event-bus.js +0 -51
- package/dist/core/event-bus.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,227 +1,394 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/cortex-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/cortex-mcp)
|
|
5
|
+
[](https://github.com/jaswanthkumarj1234-beep/cortex-mcp/actions/workflows/ci.yml)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
> Give your AI coding assistant a brain that remembers across sessions.
|
|
10
|
+
|
|
11
|
+
Cortex is an MCP (Model Context Protocol) server that provides persistent, intelligent memory to any AI coding assistant — Cursor, Claude Code, Windsurf, Cline, or any MCP-compatible tool.
|
|
12
|
+
|
|
13
|
+
## What's New in v2.6 — OpenClaw-Style Autonomous Brain
|
|
14
|
+
|
|
15
|
+
- **🧠 SOUL.md** — Persistent AI identity file, auto-learns from your top memories
|
|
16
|
+
- **📓 Daily Diary** — Timestamped Markdown logs of every session's decisions and insights
|
|
17
|
+
- **📄 MEMORY.md** — Human-readable knowledge export, auto-synced with the database
|
|
18
|
+
- **🎯 MMR Re-ranking** — Maximal Marginal Relevance ensures diverse search results (λ=0.7)
|
|
19
|
+
- **⚡ Embedding Cache** — LRU cache (256 entries) skips redundant vector computations
|
|
20
|
+
- **🔍 Query Expansion** — 40+ synonym groups + alternative query generation for zero-result fallback
|
|
21
|
+
- **👤 Access Pattern Tracking** — Learns which memory types you use most, boosts them 0.7x–1.8x
|
|
22
|
+
- **🔗 Cross-Memory Linking** — Auto-links related memories by files, tags, and word overlap
|
|
23
|
+
- **⏳ Two-Tier Decay** — Transactional memories (INSIGHT) decay at 5 days, operational (DECISION/CORRECTION) protected for 60 days
|
|
24
|
+
- **🤖 100% Autonomous** — All features run automatically on download, zero config needed
|
|
25
|
+
|
|
26
|
+
See [CHANGELOG.md](CHANGELOG.md) for full details.
|
|
27
|
+
|
|
28
|
+
## The Problem
|
|
29
|
+
|
|
30
|
+
Every time you start a new conversation, your AI assistant forgets everything:
|
|
31
|
+
|
|
32
|
+
- Coding conventions you already explained
|
|
33
|
+
- Bugs you already fixed
|
|
34
|
+
- Decisions you already made
|
|
35
|
+
- What files you were working on
|
|
36
|
+
|
|
37
|
+
**Cortex solves this.** It stores, ranks, and proactively recalls context so your AI never starts from zero.
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
### Option 1: npx (recommended — always up to date)
|
|
42
|
+
|
|
43
|
+
Add to your MCP config (no install needed, auto-updates on every launch):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"cortex": {
|
|
49
|
+
"command": "npx",
|
|
50
|
+
"args": ["-y", "cortex-mcp@latest"],
|
|
51
|
+
"transportType": "stdio"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 🧠 Supercharge with Free LLM (Optional)
|
|
58
|
+
|
|
59
|
+
Add a **free** OpenRouter API key to make Cortex 3x smarter at extracting knowledge:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"cortex": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "cortex-mcp@latest"],
|
|
67
|
+
"transportType": "stdio",
|
|
68
|
+
"env": {
|
|
69
|
+
"OPENROUTER_API_KEY": "sk-or-v1-your-key-here"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**How to get a free key:**
|
|
77
|
+
|
|
78
|
+
1. Go to [openrouter.ai/keys](https://openrouter.ai/keys)
|
|
79
|
+
2. Create a free account
|
|
80
|
+
3. Generate an API key
|
|
81
|
+
4. Paste it in the config above
|
|
82
|
+
|
|
83
|
+
**What it enables:** When regex can't extract patterns from your conversation, Cortex uses a free LLM (Llama 4 Scout) to catch implicit decisions, preferences, and architecture knowledge that keywords miss. Without it, ~70% of conversations produce no memories. With it, that drops to ~20%.
|
|
84
|
+
|
|
85
|
+
### Option 2: Global install
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install -g cortex-mcp
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then add to your MCP config:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"cortex": {
|
|
97
|
+
"command": "cortex-mcp",
|
|
98
|
+
"transportType": "stdio"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Option 2: Clone from source
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
git clone https://github.com/jaswanthkumarj1234-beep/cortex-mcp.git
|
|
108
|
+
cd cognitive-memory
|
|
109
|
+
npm install
|
|
110
|
+
npm run build
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Then add to your MCP config:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"cortex": {
|
|
119
|
+
"command": "node",
|
|
120
|
+
"args": ["<path-to>/cognitive-memory/dist/mcp-stdio.js"],
|
|
121
|
+
"transportType": "stdio"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Restart your IDE and Cortex is active.
|
|
128
|
+
|
|
129
|
+
### Try the Demo
|
|
130
|
+
|
|
131
|
+
See Cortex in action without any AI client:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run demo # Interactive demo — store, search, dedup
|
|
135
|
+
npm run benchmark # Performance benchmark — write, read, FTS ops/sec
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### IDE-Specific Setup Guides
|
|
139
|
+
|
|
140
|
+
Step-by-step instructions for your IDE: **[Cursor · Claude Code · Windsurf · Cline · Copilot](docs/ide-setup.md)**
|
|
141
|
+
|
|
142
|
+
### Recipes & Use Cases
|
|
143
|
+
|
|
144
|
+
10 practical examples: **[docs/recipes.md](docs/recipes.md)** — conventions, bug tracking, anti-hallucination, team onboarding, and more.
|
|
145
|
+
|
|
146
|
+
## Features
|
|
147
|
+
|
|
148
|
+
### Why Cortex?
|
|
149
|
+
|
|
150
|
+
| Feature | Cortex | Other MCP memory servers |
|
|
151
|
+
| --------------------------- | :------------------------------------------------------: | :----------------------: |
|
|
152
|
+
| **Retrieval** | Hybrid (FTS + Vector + Graph) | Usually FTS only |
|
|
153
|
+
| **Auto-learning** | Extracts memories from AI responses | Manual store only |
|
|
154
|
+
| **Hallucination detection** | `verify_code` + `verify_files` | No |
|
|
155
|
+
| **Git integration** | Auto-captures commits, diffs, branch context | No |
|
|
156
|
+
| **Cognitive features** | Decay, attention, contradiction detection, consolidation | No |
|
|
157
|
+
| **Brain pipeline** | 12+ layer context injection | Simple key-value recall |
|
|
158
|
+
| **Setup** | `npm i -g cortex-mcp` + 1 config line | Varies |
|
|
159
|
+
| **Offline** | 100% local SQLite (no API key needed) | Often requires API |
|
|
160
|
+
|
|
161
|
+
### 20 MCP Tools
|
|
162
|
+
|
|
163
|
+
| Tool | Purpose |
|
|
164
|
+
| ----------------- | ---------------------------------------------------------------------------------- |
|
|
165
|
+
| `force_recall` | Full brain dump at conversation start (12+ layer pipeline) |
|
|
166
|
+
| `recall_memory` | Search memories by topic (FTS + vector + graph) |
|
|
167
|
+
| `store_memory` | Store a decision, correction, convention, or bug fix |
|
|
168
|
+
| `quick_store` | One-liner memory storage with auto-classification |
|
|
169
|
+
| `auto_learn` | Extract memories from AI responses automatically |
|
|
170
|
+
| `scan_project` | Scan project structure, stack, git, exports, architecture |
|
|
171
|
+
| `verify_code` | Check if imports/exports/env vars actually exist |
|
|
172
|
+
| `verify_files` | Check if file paths are real or hallucinated |
|
|
173
|
+
| `get_context` | Get compressed context for current file |
|
|
174
|
+
| `review_code` | Review code against stored conventions and past bug patterns |
|
|
175
|
+
| `pre_check` | Pre-flight check before editing — get all conventions and past bugs for a file |
|
|
176
|
+
| `check_impact` | Impact analysis — check which files depend on the file you plan to modify |
|
|
177
|
+
| `resume_work` | Resume after a break — get last session summary, recent corrections, pending tasks |
|
|
178
|
+
| `get_stats` | Memory database statistics |
|
|
179
|
+
| `list_memories` | List all active memories |
|
|
180
|
+
| `update_memory` | Update an existing memory |
|
|
181
|
+
| `delete_memory` | Delete a memory |
|
|
182
|
+
| `export_memories` | Export all memories to JSON |
|
|
183
|
+
| `import_memories` | Import memories from JSON |
|
|
184
|
+
| `health_check` | Server health check |
|
|
185
|
+
|
|
186
|
+
### 14-Layer Brain Pipeline
|
|
187
|
+
|
|
188
|
+
Every conversation starts with `force_recall`, which runs 14 layers (layers 6-12 run **in parallel** for speed):
|
|
189
|
+
|
|
190
|
+
| Layer | Feature | Parallel? |
|
|
191
|
+
| :---: | ------------------------------------------------------------- | :-------: |
|
|
192
|
+
| Soul | SOUL.md — persistent AI identity and preferences | — |
|
|
193
|
+
| 0 | Session management — track what you're working on | — |
|
|
194
|
+
| 0.5 | Day 1 auto-scan — scan project on first run | — |
|
|
195
|
+
| 1 | Maintenance — decay, consolidate, soul-learn, MEMORY.md sync | — |
|
|
196
|
+
| 2 | Attention focus — detect debugging vs coding vs reviewing | — |
|
|
197
|
+
| 3 | Session continuity — resume where you left off | — |
|
|
198
|
+
| 4 | Hot corrections — frequently-corrected topics | — |
|
|
199
|
+
| 5 | Core context — corrections, decisions, conventions, bug fixes | — |
|
|
200
|
+
| 6 | Anticipation — proactive recall based on current file | ✅ |
|
|
201
|
+
| 7 | Temporal — what changed today, yesterday, this week | ✅ |
|
|
202
|
+
| 7.5 | Daily Diary — recent session logs in Markdown | ✅ |
|
|
203
|
+
| 8 | Workspace git — branch, recent commits, diffs | ✅ |
|
|
204
|
+
| 8.5 | Git memory — auto-capture commits + file changes | ✅ |
|
|
205
|
+
| 9 | Topic search — FTS + vector + MMR diversity + personal boost | ✅ |
|
|
206
|
+
| 10 | Knowledge gaps — flag files with zero memories | ✅ |
|
|
207
|
+
| 11 | Export map — all functions/classes (anti-hallucination) | ✅ |
|
|
208
|
+
| 12 | Architecture graph — layers, circular deps, API endpoints | ✅ |
|
|
209
|
+
|
|
210
|
+
### Cognitive Features
|
|
211
|
+
|
|
212
|
+
- **Confidence decay** — old unused memories fade, frequently accessed ones strengthen
|
|
213
|
+
- **Attention ranking** — debugging context boosts bug-fix memories, coding boosts conventions
|
|
214
|
+
- **Contradiction detection** — new memories automatically supersede conflicting old ones
|
|
215
|
+
- **Memory consolidation** — similar memories merge into higher-level insights
|
|
216
|
+
- **Cross-session threading** — related sessions link by topic overlap
|
|
217
|
+
- **Learning rate** — topics corrected 3+ times get CRITICAL priority
|
|
218
|
+
|
|
219
|
+
### Performance & Reliability
|
|
220
|
+
|
|
221
|
+
- **`force_recall` latency**: ~3-5s first call, instant on cache hit (v1.2 — was 15-19s)
|
|
222
|
+
- **`recall_memory` latency**: <1ms average (local SQLite + WAL)
|
|
223
|
+
- **Throughput**: 1800+ ops/sec (verified via Soak Test)
|
|
224
|
+
- **Stability**: Zero memory leaks over sustained operation
|
|
225
|
+
- **Protocol**: Full JSON-RPC 2.0 compliance (passed E2E suite)
|
|
226
|
+
- **CI**: Tested on Node 18, 20, 22 with lint + build + E2E on every push
|
|
227
|
+
|
|
228
|
+
### Anti-Hallucination
|
|
229
|
+
|
|
230
|
+
- Deep export map scans every source file for all exported functions, classes, types
|
|
231
|
+
- When AI references a function that doesn't exist, `verify_code` suggests the closest real match
|
|
232
|
+
- Architecture graph shows actual project layers and dependencies
|
|
233
|
+
|
|
234
|
+
## Optional: LLM Enhancement
|
|
235
|
+
|
|
236
|
+
Cortex works fully without any API key. Optionally, add an LLM key for smarter memory extraction:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Option 1: OpenAI
|
|
240
|
+
set OPENAI_API_KEY=sk-your-key
|
|
241
|
+
|
|
242
|
+
# Option 2: Anthropic
|
|
243
|
+
set ANTHROPIC_API_KEY=sk-ant-your-key
|
|
244
|
+
|
|
245
|
+
# Option 3: Local (Ollama, free)
|
|
246
|
+
set CORTEX_LLM_KEY=ollama
|
|
247
|
+
set CORTEX_LLM_BASE_URL=http://localhost:11434
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Memory Types
|
|
251
|
+
|
|
252
|
+
| Type | Use For |
|
|
253
|
+
| ------------------- | --------------------------------------------------- |
|
|
254
|
+
| `CORRECTION` | "Don't use var, use const" |
|
|
255
|
+
| `DECISION` | "We chose PostgreSQL over MongoDB" |
|
|
256
|
+
| `CONVENTION` | "All API routes start with /api/v1" |
|
|
257
|
+
| `BUG_FIX` | "Fixed race condition in auth middleware" |
|
|
258
|
+
| `INSIGHT` | "The codebase uses a layered architecture" |
|
|
259
|
+
| `FAILED_SUGGESTION` | "Tried Redis caching, too complex for this project" |
|
|
260
|
+
| `PROVEN_PATTERN` | "useDebounce hook works well for search inputs" |
|
|
261
|
+
|
|
262
|
+
## Architecture
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
src/
|
|
266
|
+
├── server/ # MCP handler (12+ layer brain pipeline) + dashboard
|
|
267
|
+
├── memory/ # 25+ cognitive modules (decay, MMR, embedding cache, soul, diary, etc.)
|
|
268
|
+
├── scanners/ # Project scanner, code verifier, export map, architecture graph
|
|
269
|
+
├── db/ # SQLite storage, event log
|
|
270
|
+
├── security/ # Rate limiter, encryption
|
|
271
|
+
├── hooks/ # Git capture
|
|
272
|
+
├── config/ # Configuration
|
|
273
|
+
└── cli/ # Setup wizard
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Pricing & Features
|
|
277
|
+
|
|
278
|
+
Cortex is open core. The basic version is free forever. To unlock deep cognitive features, upgrade to PRO.
|
|
279
|
+
|
|
280
|
+
| Feature | FREE (npm install) | PRO ($9/mo) |
|
|
281
|
+
| ----------------------------------- | :----------------: | :---------: |
|
|
282
|
+
| **Memory Capacity** | ∞ Unlimited | ∞ Unlimited |
|
|
283
|
+
| **Brain Layers** | 12+ (Full) | 12+ (Full) |
|
|
284
|
+
| **All 16 Tools** | Yes | Yes |
|
|
285
|
+
| **Auto-Learn** | Yes | Yes |
|
|
286
|
+
| **Export Map (Anti-Hallucination)** | Yes | Yes |
|
|
287
|
+
| **Architecture Graph** | Yes | Yes |
|
|
288
|
+
| **Git Memory** | Yes | Yes |
|
|
289
|
+
| **Confidence Decay** | Yes | Yes |
|
|
290
|
+
| **Contradiction Detection** | Yes | Yes |
|
|
291
|
+
| **Priority Support** | — | Yes |
|
|
292
|
+
|
|
293
|
+
> **Launch Edition**: All features are currently free. Get started now and lock in lifetime access.
|
|
294
|
+
|
|
295
|
+
### Activate PRO
|
|
296
|
+
|
|
297
|
+
1. Get a license key from your [Cortex AI Dashboard](https://cortex-ai-iota.vercel.app/dashboard)
|
|
298
|
+
2. Set it in your environment:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Option A: Environment variable
|
|
302
|
+
export CORTEX_LICENSE_KEY=CORTEX-XXXX-XXXX-XXXX-XXXX
|
|
303
|
+
|
|
304
|
+
# Option B: License file
|
|
305
|
+
echo CORTEX-XXXX-XXXX-XXXX-XXXX > ~/.cortex/license
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
3. Restart your IDE / MCP server.
|
|
309
|
+
|
|
310
|
+
## Architecture
|
|
311
|
+
|
|
312
|
+
```mermaid
|
|
313
|
+
graph TB
|
|
314
|
+
AI["AI Client (Cursor, Claude, etc.)"]
|
|
315
|
+
MCP["MCP Server (stdio)"]
|
|
316
|
+
ML["Memory Layer"]
|
|
317
|
+
DB["SQLite Database"]
|
|
318
|
+
SEC["Security Layer"]
|
|
319
|
+
API["License API"]
|
|
320
|
+
|
|
321
|
+
AI -->|"JSON-RPC via stdio"| MCP
|
|
322
|
+
MCP --> ML
|
|
323
|
+
ML --> DB
|
|
324
|
+
MCP --> SEC
|
|
325
|
+
SEC -->|"verify license"| API
|
|
326
|
+
|
|
327
|
+
subgraph "Memory Layer"
|
|
328
|
+
ML --> EMB["Embedding Manager"]
|
|
329
|
+
ML --> AL["Auto-Learner"]
|
|
330
|
+
ML --> QG["Quality Gates"]
|
|
331
|
+
ML --> TD["Temporal Decay"]
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
subgraph "Retrieval"
|
|
335
|
+
ML --> HR["Hybrid Retriever"]
|
|
336
|
+
HR --> VS["Vector Search"]
|
|
337
|
+
HR --> FTS["Full-Text Search"]
|
|
338
|
+
HR --> RR["Recency Ranker"]
|
|
339
|
+
end
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## FAQ / Troubleshooting
|
|
343
|
+
|
|
344
|
+
<details>
|
|
345
|
+
<summary><strong>Cortex doesn't start or my AI client can't connect</strong></summary>
|
|
346
|
+
|
|
347
|
+
1. Make sure Node.js >=18 is installed: `node --version`
|
|
348
|
+
2. Try running manually: `npx cortex-mcp` — check stderr for errors
|
|
349
|
+
3. Check if another Cortex instance is running on the same workspace
|
|
350
|
+
4. Delete the cache and restart: `rm -rf .ai/brain-data`
|
|
351
|
+
</details>
|
|
352
|
+
|
|
353
|
+
<details>
|
|
354
|
+
<summary><strong>Memories aren't being recalled</strong></summary>
|
|
355
|
+
|
|
356
|
+
1. Confirm your AI client's system prompt includes the Cortex rules (run `cortex-setup` to install them)
|
|
357
|
+
2. Check the dashboard at `http://localhost:3456` to see stored memories
|
|
358
|
+
3. Verify memories exist: the AI should call `force_recall` at conversation start
|
|
359
|
+
</details>
|
|
360
|
+
|
|
361
|
+
<details>
|
|
362
|
+
<summary><strong>"better-sqlite3" build errors on install</strong></summary>
|
|
363
|
+
|
|
364
|
+
`better-sqlite3` requires a C++ compiler:
|
|
365
|
+
|
|
366
|
+
- **Windows**: Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
|
|
367
|
+
- **macOS**: Run `xcode-select --install`
|
|
368
|
+
- **Linux**: Run `sudo apt-get install build-essential python3`
|
|
369
|
+
</details>
|
|
370
|
+
|
|
371
|
+
<details>
|
|
372
|
+
<summary><strong>License key not working</strong></summary>
|
|
373
|
+
|
|
374
|
+
1. Verify the key format: `CORTEX-XXXX-XXXX-XXXX-XXXX`
|
|
375
|
+
2. Check your internet connection (license is verified online on first use)
|
|
376
|
+
3. Clear the cache: `rm ~/.cortex/license-cache.json`
|
|
377
|
+
4. Try setting it via environment variable: `export CORTEX_LICENSE_KEY=CORTEX-...`
|
|
378
|
+
</details>
|
|
379
|
+
|
|
380
|
+
<details>
|
|
381
|
+
<summary><strong>Dashboard not loading</strong></summary>
|
|
382
|
+
|
|
383
|
+
1. Default port is 3456. Check if something else is using it: `lsof -i :3456`
|
|
384
|
+
2. Set a custom port: `export CORTEX_PORT=4000`
|
|
385
|
+
3. The dashboard URL is shown in your AI client's stderr on startup
|
|
386
|
+
</details>
|
|
387
|
+
|
|
388
|
+
## Contributing
|
|
389
|
+
|
|
390
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, and the PR process.
|
|
391
|
+
|
|
392
|
+
## License
|
|
393
|
+
|
|
394
|
+
MIT
|