Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Harper Cortex - Environment Variables
# Cortex - Environment Variables
# =============================================================================
# Copy this file to .env and fill in your values:
# cp .env.example .env
Expand All @@ -15,9 +15,9 @@ CLI_TARGET_PASSWORD=your_admin_password
# Get your API key at https://console.anthropic.com/
ANTHROPIC_API_KEY=sk-ant-xxxxx

# --- Voyage AI (for vector embeddings) ---
# Get your API key at https://dash.voyageai.com/
VOYAGE_API_KEY=pa-xxxxx
# --- Embeddings ---
# Embeddings are generated locally using ONNX (Xenova/all-MiniLM-L6-v2).
# No API key needed — runs in-process on first call (downloads ~23MB model once).

# --- Slack (for webhook ingestion) ---
# Create a Slack app at https://api.slack.com/apps
Expand Down
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Harper-Cortex
# Cortex

An agent-agnostic AI memory system using Harper Fabric as the vector database and MCP for AI agent connectivity.

Expand All @@ -7,7 +7,7 @@ An agent-agnostic AI memory system using Harper Fabric as the vector database an
- **Runtime**: Harper (Node.js-based, ES modules)
- **Database**: Harper Fabric with HNSW vector indexing
- **Classification**: Anthropic Claude Haiku 3.5 (`claude-haiku-3-5-20241022`)
- **Embeddings**: Voyage AI `voyage-3` (1024-dim)
- **Embeddings**: `@xenova/transformers` with `all-MiniLM-L6-v2` (384-dim, Harper-native ONNX)
- **Ingestion**: Slack Events API webhooks
- **AI Bridge**: Harper MCP Server + `mcp-remote`
- **Tests**: Node.js built-in test runner (`node:test`)
Expand All @@ -30,7 +30,7 @@ npm run deploy # Deploy to Harper Fabric

## Architecture

Slack webhook -> classify (Claude) + embed (Voyage AI) -> store in Memory table -> query via MCP from Claude Desktop/Cursor.
Slack webhook -> classify (Claude) + embed (@xenova/transformers) -> store in Memory table -> query via MCP from Claude Desktop/Cursor.

## Synapse

Expand All @@ -50,7 +50,7 @@ Universal Context Broker — ingests development context from any AI tool (Claud

### Conventions

- SynapseEntry table follows same patterns as Memory (HNSW vector index, classification via Claude Haiku, embeddings via Voyage AI)
- SynapseEntry table follows same patterns as Memory (HNSW vector index, classification via Claude Haiku, embeddings via @xenova/transformers)
- Use renamed import: `const { SynapseEntry: SynapseEntryBase } = tables;`
- All Synapse queries must filter on `projectId`
- Default status filter is `active` (excludes superseded/archived)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Contributing to Harper-Cortex
# Contributing to Cortex

Thanks for your interest in contributing. This guide covers how to get set up, make changes, and submit a pull request.

## Getting Started

1. Fork the repository and clone your fork:
```bash
git clone https://github.com/YOUR_USERNAME/Harper-Cortex.git
cd Harper-Cortex
git clone https://github.com/YOUR_USERNAME/Cortex.git
cd Cortex
```

2. Install dependencies:
Expand Down
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Harper-Cortex
# Cortex

A persistent, agent-agnostic AI memory system powered by [Harper Fabric](https://harper.fast). Clone, configure your API keys, deploy, and give all your AI tools a shared brain.

Expand Down Expand Up @@ -62,8 +62,8 @@ Create your free cluster at [fabric.harper.fast](https://fabric.harper.fast):
### 2. Clone and install

```bash
git clone https://github.com/HarperFast/Harper-Cortex.git
cd Harper-Cortex
git clone https://github.com/HarperFast/Cortex.git
cd Cortex
npm install -g harperdb # Install the Harper runtime (one-time)
npm install # Install project dependencies
```
Expand All @@ -75,7 +75,6 @@ Sign up for these services and grab your API keys. All have free tiers.
| Service | Sign Up | What You Need |
| ------------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **Anthropic** | [console.anthropic.com](https://console.anthropic.com/) | API key (used for message classification) |
| **Voyage AI** | [dash.voyageai.com](https://dash.voyageai.com/) | API key (used for vector embeddings) |
| **Slack** | [api.slack.com/apps](https://api.slack.com/apps) | Create a Slack app. See [docs/slack-app-setup.md](docs/slack-app-setup.md) for the full walkthrough. |

### 4. Configure environment
Expand Down Expand Up @@ -123,13 +122,12 @@ See [docs/mcp-setup.md](docs/mcp-setup.md) for configuration instructions.
| Variable | Required | Description |
| ---------------------- | --------------- | ------------------------------------------------------------------------ |
| `ANTHROPIC_API_KEY` | Yes | Anthropic API key for Claude (message classification) |
| `VOYAGE_API_KEY` | Yes | Voyage AI API key (vector embedding generation) |
| `SLACK_SIGNING_SECRET` | For Slack | Slack app signing secret (webhook verification) |
| `SLACK_BOT_TOKEN` | For Slack | Slack bot user OAuth token (`xoxb-...`) |
| `CLI_TARGET` | For deploy | Harper Fabric cluster URL (e.g., `https://cluster.org.harperfabric.com`) |
| `CLI_TARGET_USERNAME` | For deploy | Harper cluster admin username |
| `CLI_TARGET_PASSWORD` | For deploy | Harper cluster admin password |
| `SYNAPSE_ENDPOINT` | For Synapse CLI | Base URL of Harper-Cortex deployment |
| `SYNAPSE_ENDPOINT` | For Synapse CLI | Base URL of Cortex deployment |
| `SYNAPSE_PROJECT` | For Synapse CLI | Project ID to scope context entries |
| `SYNAPSE_AUTH` | For Synapse CLI | Authorization header (e.g. `Basic dXNlcjpwYXNz`) |

Expand Down Expand Up @@ -207,21 +205,21 @@ Tests use Node.js built-in test runner with module mocking. No extra test depend

1. **A source sends an event** via webhook (e.g. Slack message, GitHub issue, Linear task)
2. **Classification**: Claude Haiku categorizes the content (decision, action_item, knowledge, etc.) and extracts entities (people, projects, technologies)
3. **Embedding**: Voyage AI generates a 1024-dimensional vector embedding
3. **Embedding**: A local ONNX model (`all-MiniLM-L6-v2`) generates a 384-dimensional vector embedding — no API key required
4. **Storage**: Raw text, classification, entities, and embedding are stored in the Memory table with HNSW vector indexing
5. **Retrieval**: Any MCP-connected AI client queries the Memory table using hybrid search (vector similarity + attribute filters)

### Synapse: coding context (CLI / API)

1. **Ingest**: `synapse sync` reads your tool context files (CLAUDE.md, `.cursor/rules/`, `.windsurf/rules/`, `copilot-instructions.md`) and POSTs them to `/SynapseIngest`
2. **Parse**: Each source format is split into discrete entries; duplicate content is deduplicated via content hash
3. **Classify + embed**: Each entry is classified into a type (`intent`, `constraint`, `artifact`, `history`) and embedded with Voyage AI
3. **Classify + embed**: Each entry is classified into a type (`intent`, `constraint`, `artifact`, `history`) and embedded locally with `all-MiniLM-L6-v2`
4. **Storage**: Entries are stored in the SynapseEntry table with HNSW vector indexing, scoped by `projectId`
5. **Retrieval**: `synapse search` or any MCP client queries `/SynapseSearch`; `synapse emit` formats entries back into any target tool's native format

## Supported Integrations

This repo ships with Slack + Anthropic + Voyage AI as the default stack. The architecture is designed to be swappable - add a new webhook resource class for any ingestion source, or change the LLM/embedding provider in `resources.js`.
This repo ships with Slack + Anthropic + local ONNX embeddings as the default stack. The architecture is designed to be swappable add a new webhook resource class for any ingestion source, or change the LLM/embedding provider in `resources.js`.

### Ingestion Sources

Expand Down Expand Up @@ -254,12 +252,13 @@ Swap the classification model by changing `CLASSIFICATION_MODEL` in `resources.j

Swap the embedding provider by changing `generateEmbedding()` in `resources.js`. If you change the vector dimensions, re-embed all existing records.

| Provider | Recommended Model | Dimensions | Trade-off |
| ------------------ | ---------------------- | ---------- | ------------------------------- |
| **Voyage AI** | voyage-3 | 1024 | Anthropic-recommended (default) |
| **OpenAI** | text-embedding-3-small | 1536 | Most widely adopted |
| **Cohere** | embed-v4 | 1024 | Strong multilingual support |
| **Ollama** (local) | nomic-embed-text | 768 | Full privacy, zero API cost |
| Provider | Recommended Model | Dimensions | Trade-off |
| ------------------------ | ---------------------- | ---------- | -------------------------------- |
| **@xenova/transformers** | all-MiniLM-L6-v2 | 384 | Local ONNX, no API key (default) |
| **Voyage AI** | voyage-3 | 1024 | High quality, requires API key |
| **OpenAI** | text-embedding-3-small | 1536 | Most widely adopted |
| **Cohere** | embed-v4 | 1024 | Strong multilingual support |
| **Ollama** (local) | nomic-embed-text | 768 | Full privacy, zero API cost |

### MCP Clients (Retrieval)

Expand All @@ -275,7 +274,7 @@ Any MCP-compliant AI client can connect to the Harper MCP Server and query your

## Synapse: Universal Context Broker

Synapse extends Harper-Cortex into a **Universal Context Broker** — a system that bridges context across AI development tools. When you switch from Claude Code to Cursor, or add a new team member, the "Why" behind architectural decisions is normally lost. Synapse captures it.
Synapse extends Cortex into a **Universal Context Broker** — a system that bridges context across AI development tools. When you switch from Claude Code to Cursor, or add a new team member, the "Why" behind architectural decisions is normally lost. Synapse captures it.

```
INGEST (Tool → Harper) EMIT (Harper → Tool)
Expand Down Expand Up @@ -311,7 +310,7 @@ Synapse extends Harper-Cortex into a **Universal Context Broker** — a system t
# Install globally after cloning
npm install -g .

# Sync your context files to Harper-Cortex
# Sync your context files to Cortex
SYNAPSE_PROJECT=my-app synapse sync

# Search across all context
Expand Down
8 changes: 4 additions & 4 deletions bin/synapse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/**
* Synapse CLI — Universal Context Broker for Harper-Cortex
* Synapse CLI — Universal Context Broker for Cortex
*
* Commands:
* synapse sync Discover and ingest context files
Expand All @@ -10,7 +10,7 @@
* synapse status Show entry counts by type and source
*
* Environment:
* SYNAPSE_ENDPOINT Base URL of your Harper-Cortex deployment
* SYNAPSE_ENDPOINT Base URL of your Cortex deployment
* SYNAPSE_PROJECT Project ID to scope entries
* SYNAPSE_AUTH Authorization header value (e.g. "Basic dXNlcjpwYXNz")
*/
Expand Down Expand Up @@ -337,7 +337,7 @@ async function cmdWatch() {

function printHelp() {
console.log(`
Synapse — Universal Context Broker for Harper-Cortex
Synapse — Universal Context Broker for Cortex

Usage:
synapse <command> [options]
Expand All @@ -359,7 +359,7 @@ Search options:
--type <type> Filter by type: intent, constraint, artifact, history

Environment variables:
SYNAPSE_ENDPOINT Harper-Cortex base URL (default: http://localhost:9926)
SYNAPSE_ENDPOINT Cortex base URL (default: http://localhost:9926)
SYNAPSE_PROJECT Project ID (required for all commands)
SYNAPSE_AUTH Authorization header value (e.g. "Basic dXNlcjpwYXNz")

Expand Down
8 changes: 4 additions & 4 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
│ Linear │ ──▶ │ │ classifyMsg (Claude API) │ │
│ Webhooks │ │ └────────────┬────────────┘ │
└─────────────────┘ │ ┌────────────▼────────────┐ │
│ │ genEmbedding (Voyage AI) │ │
│ │ genEmbedding (ONNX local) │ │
┌─────────────────┐ │ └────────────┬────────────┘ │
│ Other Sources │ ──▶ │ ┌────────────▼────────────┐ │
│ (Discord, etc) │ │ │ Memory.put() │ │
Expand Down Expand Up @@ -61,7 +61,7 @@
| `authorName` | String | No | Human-readable author name |
| `classification` | String | Yes | LLM category (decision, action_item, etc.) |
| `entities` | Any (JSON) | No | Extracted entities (people, projects, tech) |
| `embedding` | [Float] | HNSW/cosine | 1024-dim vector from Voyage AI |
| `embedding` | [Float] | HNSW/cosine | 384-dim vector from all-MiniLM-L6-v2 (local) |
| `summary` | String | No | LLM-generated one-line summary |
| `timestamp` | Date | Yes | When the original message was sent |
| `threadTs` | String | No | Slack thread timestamp for grouping |
Expand Down Expand Up @@ -101,7 +101,7 @@ Synapse adds a second data layer alongside Memory — the `SynapseEntry` table
│ .cursor/rules/ │ │ SynapseIngest │ ──▶ .cursor/*.mdc
│ .windsurf/rules/ │ │ 1. Parse (tool-specific parser) │ ──▶ .windsurf/*.md
│ copilot-inst. │ │ 2. Classify (Claude Haiku) │ ──▶ copilot-inst.
│ manual / slack │ │ 3. Embed (Voyage AI)
│ manual / slack │ │ 3. Embed (ONNX local)
└──────────────────┘ │ 4. Store → SynapseEntry │
└──────────────────┬───────────────────┘
Expand Down Expand Up @@ -135,7 +135,7 @@ Synapse adds a second data layer alongside Memory — the `SynapseEntry` table
| `content` | String | No | Full context text |
| `source` | String | Yes | `claude_code \| cursor \| windsurf \| copilot \| manual \| slack` |
| `sourceFormat` | String | No | `markdown \| mdc \| json` |
| `embedding` | [Float] | HNSW/cosine | 1024-dim vector |
| `embedding` | [Float] | HNSW/cosine | 384-dim vector from all-MiniLM-L6-v2 (local) |
| `summary` | String | No | LLM one-liner |
| `status` | String | Yes | `active \| superseded \| archived` |
| `references` | [String] | No | Memory record IDs this traces back to |
Expand Down
4 changes: 2 additions & 2 deletions docs/mcp-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Edit the Claude Desktop configuration file:
```json
{
"mcpServers": {
"harper-cortex": {
"cortex": {
"command": "npx",
"args": [
"-y",
Expand Down Expand Up @@ -72,7 +72,7 @@ This returns `{ "jwt": "...", "refreshToken": "..." }`. Use the JWT in your conf
```json
{
"mcpServers": {
"harper-cortex": {
"cortex": {
"command": "npx",
"args": [
"-y",
Expand Down
6 changes: 3 additions & 3 deletions docs/slack-app-setup.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Slack App Setup Guide

This guide walks you through creating and configuring a Slack app to send messages to Harper-Cortex.
This guide walks you through creating and configuring a Slack app to send messages to Cortex.

## Step 1: Create the Slack App

1. Go to [api.slack.com/apps](https://api.slack.com/apps)
2. Click **Create New App** > **From scratch**
3. Name it (e.g., "Harper-Cortex Bot") and select your workspace
3. Name it (e.g., "Cortex Bot") and select your workspace
4. Click **Create App**

## Step 2: Configure Bot Token Scopes
Expand Down Expand Up @@ -60,7 +60,7 @@ If Slack asks you to reinstall the app after changing scopes or events, do so.
In each Slack channel you want monitored, type:

```
/invite @Harper-Cortex Bot
/invite @Cortex Bot
```

(Use whatever name you gave your app in Step 1.)
Expand Down
8 changes: 4 additions & 4 deletions docs/synapse-design.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Synapse: Universal Context Broker for Harper-Cortex
# Synapse: Universal Context Broker for Cortex

## Context

AI development tools (Claude Code, Cursor, Windsurf, Copilot) each build their own "contextual debt" — session history, rules files, memory banks — that is invisible to other tools. When engineers switch harnesses, the "Why" behind architectural decisions is lost.

Synapse transforms Harper-Cortex into a **Universal Context Broker**: any tool can write structured context to Harper, and any other tool can read it in its native format. Harper becomes the single source of truth for development context.
Synapse transforms Cortex into a **Universal Context Broker**: any tool can write structured context to Harper, and any other tool can read it in its native format. Harper becomes the single source of truth for development context.

## Architecture Overview

Expand Down Expand Up @@ -106,7 +106,7 @@ Accepts `{ source, content, projectId, parentId?, references? }`:

1. Validates input
2. Calls source-specific **parser** to split content into entries
3. For each entry: classify (Claude Haiku) + embed (Voyage AI) in parallel
3. For each entry: classify (Claude Haiku) + embed (all-MiniLM-L6-v2 via @xenova/transformers) in parallel
4. Stores as SynapseEntry records

**Parsers** (one per tool):
Expand Down Expand Up @@ -222,4 +222,4 @@ After each phase:
- `npm test` — all existing + new tests pass
- `npm run dev` — endpoints respond at `localhost:9926`
- Manual: POST to `/SynapseIngest` with a CLAUDE.md, then `/SynapseSearch` to retrieve, then `/SynapseEmit --target cursor` to format
- After Phase 4: `synapse sync && synapse search "architecture" && synapse emit --target cursor` in the Harper-Cortex project itself
- After Phase 4: `synapse sync && synapse search "architecture" && synapse emit --target cursor` in the Cortex project itself
Loading
Loading